当前位置: 首页>>代码示例>>Java>>正文


Java MessageContext.setTo方法代码示例

本文整理汇总了Java中org.apache.axis2.context.MessageContext.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setTo方法的具体用法?Java MessageContext.setTo怎么用?Java MessageContext.setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis2.context.MessageContext的用法示例。


在下文中一共展示了MessageContext.setTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWSDL

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Retrieves the WSDL data associated with the given serviceURL.
 * @param out The output stream for the WSDL data to be written, NOTE: the stream is not closed after the operation, 
 *            it is the responsibility of the caller to close the stream after usage.
 * @param serviceURL The fist element of this array i.e. serviceURL[0] is taken in retrieving the target service.
 */
private void getWSDL(OutputStream out, String[] serviceURL)
		throws AxisFault {
	// Retrieve WSDL using the same data retrieval path for GetMetadata
	// request.
	DataRetrievalRequest request = new DataRetrievalRequest();
	request.putDialect(DRConstants.SPEC.DIALECT_TYPE_WSDL);
	request.putOutputForm(OutputForm.INLINE_FORM);

	MessageContext context = new MessageContext();
	context.setAxisService(this);
	context.setTo(new EndpointReference(serviceURL[0]));

	Data[] result = getData(request, context);
	OMElement wsdlElement;
	if (result != null && result.length > 0) {
		wsdlElement = (OMElement) (result[0].getData());
		try {
			XMLPrettyPrinter.prettify(wsdlElement, out);
			out.flush();
		} catch (Exception e) {
			throw AxisFault.makeFault(e);
		}
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:31,代码来源:AxisService.java

示例2: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc, ConfigurationContext cc,
                                                int flowType) throws Exception {
        MessageContext mc = cc.createMessageContext();

        mc.setFLOW(flowType);
        mc.setTransportIn(transportIn);
        mc.setTransportOut(transportOut);

        mc.setServerSide(true);
//        mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);

        SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
        mc.setEnvelope(omFac.getDefaultEnvelope());

        AxisOperation axisOperation = oc.getAxisOperation();
        String action = axisOperation.getName().getLocalPart();
        mc.setSoapAction(action);
//        System.out.flush();

        mc.setMessageID(UUIDGenerator.getUUID());

        axisOperation.registerOperationContext(mc, oc);
        mc.setOperationContext(oc);

        ServiceContext sc = oc.getServiceContext();
        mc.setServiceContext(sc);

        mc.setTo(new EndpointReference("axis2/services/NullService"));
        mc.setWSAAction("DummyOp");

        AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        mc.setAxisMessage(axisMessage);

        return mc;
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:36,代码来源:MessageContextSaveCTest.java

示例3: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc) throws Exception {
        MessageContext mc = configurationContext.createMessageContext();
        mc.setTransportIn(transportIn);
        mc.setTransportOut(transportOut);

        mc.setServerSide(true);
//        mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);

        SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
        mc.setEnvelope(omFac.getDefaultEnvelope());

        AxisOperation axisOperation = oc.getAxisOperation();
        String action = axisOperation.getName().getLocalPart();
        mc.setSoapAction(action);
//        System.out.flush();

        mc.setMessageID(UUIDGenerator.getUUID());

        axisOperation.registerOperationContext(mc, oc);
        mc.setOperationContext(oc);

        ServiceContext sc = oc.getServiceContext();
        mc.setServiceContext(sc);

        mc.setTo(new EndpointReference("axis2/services/NullService"));
        mc.setWSAAction("DummyOp");

        AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        mc.setAxisMessage(axisMessage);

        return mc;
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:MessageContextSaveBTest.java

示例4: echoRedirect

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement echoRedirect(OMElement ome) throws AxisFault {
    System.out.println("MultiHopRedirectService2");
    MessageContext currInMc = MessageContext.getCurrentMessageContext();
    MessageContext currOutMc = currInMc.getOperationContext().getMessageContext("Out");
    currOutMc.setTo(currInMc.getReplyTo());
    currOutMc.getRelatesTo().setValue(currInMc.getRelatesTo().getValue());
    return ome;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:MultiHopRedirectService2.java

示例5: echoRedirect

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement echoRedirect(OMElement ome) throws AxisFault {
    MessageContext currInMc = MessageContext.getCurrentMessageContext();
    MessageContext currOutMc = currInMc.getOperationContext().getMessageContext("Out");
    currOutMc.setTo(new EndpointReference("http://127.0.0.1:" + (UtilServer.TESTING_PORT) +
            "/axis2/services/MultiHopRedirectService2/echoRedirect"));
    currOutMc.setReplyTo(currInMc.getReplyTo());
    return ome;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:MultiHopRedirectService1.java

示例6: setDefaults

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void setDefaults(boolean[] alreadyFoundAddrHeader, MessageContext messageContext, String namespace) {
    if (Final.WSA_NAMESPACE.equals(namespace)) {
        //According to the WS-Addressing spec, we should default the wsa:To header to the
        //anonymous URI. Doing that, however, might prevent a different value from being
        //used instead, such as the transport URL. Therefore, we only apply the default
        //on the inbound response side of a synchronous request-response exchange.
        if (!alreadyFoundAddrHeader[TO_FLAG] && !messageContext.isServerSide()) {
            if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                log.trace(messageContext.getLogIDString() +
                " setDefaults: Setting WS-Addressing default value for the To property.");
            }
            messageContext.setTo(new EndpointReference(Final.WSA_ANONYMOUS_URL));
        }
        
        if (!alreadyFoundAddrHeader[REPLYTO_FLAG]) {
            messageContext.setReplyTo(new EndpointReference(Final.WSA_ANONYMOUS_URL));
            if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                log.trace(messageContext.getLogIDString() +
                " setDefaults: Setting WS-Addressing default value for the ReplyTo property.");
            }
        }
    }
    else {
        //The none URI is not defined in the 2004/08 spec, but it is used here anyway
        //as a flag to indicate the correct semantics to apply, i.e. in the 2004/08 spec
        //the absence of a ReplyTo header indicates that a response is NOT required.
        if (!alreadyFoundAddrHeader[REPLYTO_FLAG]) {
            messageContext.setReplyTo(new EndpointReference(Final.WSA_NONE_URI));
            if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                log.trace(
                        "setDefaults: Setting WS-Addressing default value for the ReplyTo property.");
            }
        }            
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:36,代码来源:AddressingInHandler.java

示例7: processHTTPGetRequest

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * @param msgContext           - The MessageContext of the Request Message
 * @param out                  - The output stream of the response
 * @param soapAction           - SoapAction of the request
 * @param requestURI           - The URL that the request came to
 * @param configurationContext - The Axis Configuration Context
 * @param requestParameters    - The parameters of the request message
 * @return - boolean indication whether the operation was succesfull
 * @throws AxisFault - Thrown in case a fault occurs
 * @deprecated use RESTUtil.processURLRequest(MessageContext msgContext, OutputStream out, String contentType) instead
 */

public static boolean processHTTPGetRequest(MessageContext msgContext,
                                            OutputStream out, String soapAction,
                                            String requestURI,
                                            ConfigurationContext configurationContext,
                                            Map requestParameters)
        throws AxisFault {
    if ((soapAction != null) && soapAction.startsWith("\"") && soapAction.endsWith("\"")) {
        soapAction = soapAction.substring(1, soapAction.length() - 1);
    }

    msgContext.setSoapAction(soapAction);
    msgContext.setTo(new EndpointReference(requestURI));
    msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
    msgContext.setServerSide(true);
    SOAPEnvelope envelope = HTTPTransportUtils.createEnvelopeFromGetRequest(requestURI,
                                                                            requestParameters,
                                                                            configurationContext);

    if (envelope == null) {
        return false;
    } else {
        msgContext.setDoingREST(true);
        msgContext.setEnvelope(envelope);
        AxisEngine.receive(msgContext);
        return true;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:40,代码来源:HTTPTransportUtils.java

示例8: addRoutingInfo

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Adds the required routing information to the message by adding the <code>wsa:To</code>, <code>wsa:Action</code>
 * and <code>ebint:RoutingInput</code> EPR parameter WS-A headers to the message.
 * <p>NOTE: The actual elements are added to the SOAP envelop later by the WS-A module.
 *
 * @param mc            The current message context
 * @param usrMessage    The User Message the routing input has to be deferred from
 * @param signal        The Signal message for which the routing input must be added
 */
private void addRoutingInfo(final MessageContext mc, final IUserMessage usrMessage, final ISignalMessage signal) {
    // wsa:To
    final EndpointReference toEpr = new EndpointReference(MultiHopConstants.WSA_TO_ICLOUD);

    /* ebint:RoutingInput EPR parameter
    *  The info is the same as contained in the referenced user message but with the To and From swapped and the
    *  MPC and Action extended.
    *  To create this parameter we first create a MessageMetaData object based on the UserMessage and then change
    *  the required fields
    */
    final UserMessage routingInputUsrMsg = new UserMessage(usrMessage);
    // Swap To and From
    routingInputUsrMsg.setReceiver(usrMessage.getSender());
    routingInputUsrMsg.setSender(usrMessage.getReceiver());
    // Extend Action
    routingInputUsrMsg.getCollaborationInfo().setAction(usrMessage.getCollaborationInfo().getAction()
                                                        + MultiHopConstants.GENERAL_RESP_SUFFIX);
    // Extend MPC
    if (signal instanceof IReceipt)
        routingInputUsrMsg.setMPC(usrMessage.getMPC() + MultiHopConstants.RECEIPT_SUFFIX);
    else
        routingInputUsrMsg.setMPC(usrMessage.getMPC() + MultiHopConstants.ERROR_SUFFIX);

    // Create the ebint:RoutingInput element and add it as reference parameter to the To EPR
    toEpr.addReferenceParameter(RoutingInput.createElement(mc.getEnvelope(), routingInputUsrMsg));

    mc.setTo(toEpr);

    // wsa:Action header
    if (signal instanceof IReceipt)
        mc.getOptions().setAction(MultiHopConstants.ONE_WAY_ACTION + MultiHopConstants.RECEIPT_SUFFIX);
    else
        mc.getOptions().setAction(MultiHopConstants.ONE_WAY_ACTION + MultiHopConstants.ERROR_SUFFIX);

    // Set nextMSH as target for the WS-A headers
    mc.setProperty(AddressingConstants.SOAP_ROLE_FOR_ADDRESSING_HEADERS, MultiHopConstants.NEXT_MSH_TARGET);

    // Enable use of WS-A, but prevent optional WS-A headers to be added
    mc.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.FALSE);
    mc.setProperty(AddressingConstants.INCLUDE_OPTIONAL_HEADERS, Boolean.FALSE);
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:51,代码来源:ConfigureMultihop.java

示例9: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Creates message context using values received in XMPP packet
 * @param packet
 * @return MessageContext
 * @throws AxisFault
 */
private MessageContext createMessageContext(Packet packet) throws AxisFault {
	Message message = (Message) packet;		

	Boolean isServerSide = (Boolean) message
			.getProperty(XMPPConstants.IS_SERVER_SIDE);
	String serviceName = (String) message
			.getProperty(XMPPConstants.SERVICE_NAME);
	String action = (String) message.getProperty(XMPPConstants.ACTION);
	MessageContext msgContext = null;

	TransportInDescription transportIn = configurationContext
			.getAxisConfiguration().getTransportIn("xmpp");
	TransportOutDescription transportOut = configurationContext
			.getAxisConfiguration().getTransportOut("xmpp");
	if ((transportIn != null) && (transportOut != null)) {
		msgContext = configurationContext.createMessageContext();
		msgContext.setTransportIn(transportIn);
		msgContext.setTransportOut(transportOut);
		if (isServerSide != null) {
			msgContext.setServerSide(isServerSide.booleanValue());
		}
		msgContext.setProperty(
				CONTENT_TYPE,
				"text/xml");
		msgContext.setProperty(
				Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
		msgContext.setIncomingTransportName("xmpp");

		Map services = configurationContext.getAxisConfiguration()
				.getServices();

		AxisService axisService = (AxisService) services.get(serviceName);
		msgContext.setAxisService(axisService);
		msgContext.setSoapAction(action);

		// pass the configurationFactory to transport sender
		msgContext.setProperty("XMPPConfigurationFactory",
				this.xmppConnectionFactory);

		if (packet.getFrom() != null) {
			msgContext.setFrom(new EndpointReference(packet.getFrom()));
		}
		if (packet.getTo() != null) {
			msgContext.setTo(new EndpointReference(packet.getTo()));
		}

		XMPPOutTransportInfo xmppOutTransportInfo = new XMPPOutTransportInfo();
		xmppOutTransportInfo
				.setConnectionFactory(this.xmppConnectionFactory);

		String packetFrom = packet.getFrom();
		if (packetFrom != null) {
			EndpointReference fromEPR = new EndpointReference(packetFrom);
			xmppOutTransportInfo.setFrom(fromEPR);
			xmppOutTransportInfo.setDestinationAccount(packetFrom);
		}

		// Save Message-Id to set as In-Reply-To on reply
		String xmppMessageId = packet.getPacketID();
		if (xmppMessageId != null) {
			xmppOutTransportInfo.setInReplyTo(xmppMessageId);
		}
		xmppOutTransportInfo.setSequenceID((String)message.getProperty(XMPPConstants.SEQUENCE_ID));
		msgContext.setProperty(
				org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
				xmppOutTransportInfo);
		buildSOAPEnvelope(packet, msgContext);
	} else {
		throw new AxisFault("Either transport in or transport out is null");
	}
	return msgContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:79,代码来源:XMPPPacketListener.java

示例10: WSAHeaderWriter

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public WSAHeaderWriter(MessageContext mc, boolean isSubmissionNamespace, boolean addMU,
                       boolean replace, boolean includeOptional, String role) {
    if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
        log.debug("WSAHeaderWriter: isFinal=" + !isSubmissionNamespace + " addMU=" + addMU +
                " replace=" + replace + " includeOptional=" + includeOptional+" role="+role);
    }

    messageContext = mc;
    envelope = mc.getEnvelope();
    factory = (SOAPFactory)envelope.getOMFactory();

    messageContextOptions = messageContext.getOptions();

    addressingNamespace =
            isSubmissionNamespace ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;

    header = envelope.getHeader();
    // if there is no soap header in the envelope being processed, add one.
    if (header == null) {
    	header = factory.createSOAPHeader(envelope);
    }else{
    	ArrayList addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
    	if(addressingHeaders!=null && !addressingHeaders.isEmpty()){
    		existingWSAHeaders = new ArrayList(addressingHeaders.size());
    		for(Iterator iter=addressingHeaders.iterator();iter.hasNext();){
    			SOAPHeaderBlock oe = (SOAPHeaderBlock)iter.next();
    			if(addressingRole == null || addressingRole.length() ==0 || addressingRole.equals(oe.getRole())){
    				existingWSAHeaders.add(oe.getLocalName());
    			}
    		}
    	}
    	if(addressingHeaders != null && addressingHeaders.size() ==0){
    		addressingHeaders = null;
    	}
    }
    
    isFinalAddressingNamespace = !isSubmissionNamespace;
    addMustUnderstandAttribute = addMU;
    replaceHeaders = replace;
    includeOptionalHeaders = includeOptional;
    addressingRole = role;
    
    if(!isFinalAddressingNamespace && mc.getTo() == null){
    	mc.setTo(new EndpointReference(AddressingConstants.Submission.WSA_ANONYMOUS_URL));
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:47,代码来源:AddressingOutHandler.java

示例11: testAddToSOAPHeader

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testAddToSOAPHeader() throws Exception {
    EndpointReference replyTo = new EndpointReference(
            "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
    EndpointReference epr = new EndpointReference("http://www.to.org/service/");

    for (int i = 0; i < 5; i++) {
        epr.addReferenceParameter(
                new QName(Submission.WSA_NAMESPACE, "Reference" + i,
                          AddressingConstants.WSA_DEFAULT_PREFIX),
                "Value " + i * 100);

    }


    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();

    ConfigurationContext configCtx =
            ConfigurationContextFactory.createEmptyConfigurationContext();
    MessageContext msgCtxt = configCtx.createMessageContext();
    msgCtxt.setProperty(WS_ADDRESSING_VERSION, Submission.WSA_NAMESPACE);
    msgCtxt.setTo(epr);
    msgCtxt.setReplyTo(replyTo);
    msgCtxt.setEnvelope(defaultEnvelope);
    msgCtxt.setWSAAction("http://www.actions.org/action");
    msgCtxt.setMessageID("urn:test:123");

    OMAttribute extAttr = OMAbstractFactory.getOMFactory().createOMAttribute("AttrExt",
                                                                             OMAbstractFactory
                                                                                     .getOMFactory().createOMNamespace(
                                                                                     "http://ws.apache.org/namespaces/axis2",
                                                                                     "axis2"),
                                                                             "123456789");
    ArrayList al = new ArrayList();
    al.add(extAttr);

    msgCtxt.setProperty(AddressingConstants.ACTION_ATTRIBUTES, al);
    msgCtxt.setProperty(AddressingConstants.MESSAGEID_ATTRIBUTES, al);

    outHandler.invoke(msgCtxt);

    OMXMLParserWrapper omBuilder = TestUtil.getOMBuilder("eprTest.xml");

    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual(omBuilder.getDocumentElement().toString(), defaultEnvelope.toString());

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:48,代码来源:AddressingOutHandlerTest.java

示例12: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * @param request
 * @param response
 * @param invocationType : If invocationType=true; then this will be used in SOAP message
 *                       invocation. If invocationType=false; then this will be used in REST message invocation.
 * @return MessageContext
 * @throws IOException
 */
protected MessageContext createMessageContext(HttpServletRequest request,
                                              HttpServletResponse response,
                                              boolean invocationType) throws IOException {
    MessageContext msgContext = configContext.createMessageContext();
    String requestURI = request.getRequestURI();

    String trsPrefix = request.getRequestURL().toString();
    int sepindex = trsPrefix.indexOf(':');
    if (sepindex > -1) {
        trsPrefix = trsPrefix.substring(0, sepindex);
        msgContext.setIncomingTransportName(trsPrefix);
    } else {
        msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
        trsPrefix = Constants.TRANSPORT_HTTP;
    }
    TransportInDescription transportIn =
            axisConfiguration.getTransportIn(msgContext.getIncomingTransportName());
    //set the default output description. This will be http

    TransportOutDescription transportOut = axisConfiguration.getTransportOut(trsPrefix);
    if (transportOut == null) {
        // if the req coming via https but we do not have a https sender
        transportOut = axisConfiguration.getTransportOut(Constants.TRANSPORT_HTTP);
    }


    msgContext.setTransportIn(transportIn);
    msgContext.setTransportOut(transportOut);
    msgContext.setServerSide(true);

    if (!invocationType) {
        String query = request.getQueryString();
        if (query != null) {
            requestURI = requestURI + "?" + query;
        }
    }

    msgContext.setTo(new EndpointReference(requestURI));
    msgContext.setFrom(new EndpointReference(request.getRemoteAddr()));
    msgContext.setProperty(MessageContext.REMOTE_ADDR, request.getRemoteAddr());
    msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
            new ServletBasedOutTransportInfo(response));
    // set the transport Headers
    msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, getTransportHeaders(request));
    msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, request);
    msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, response);
    try {
        ServletContext context = getServletContext();
        if(context != null) {
            msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT, context);
        }
    } catch (Exception e){
        log.debug(e.getMessage(), e);
    }

    //setting the RequestResponseTransport object
    msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
            new ServletRequestResponseTransport());

    return msgContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:70,代码来源:AxisServlet.java

示例13: initializeMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static int initializeMessageContext(MessageContext msgContext,
                                            String soapActionHeader,
                                            String requestURI,
                                            String contentType) {
    int soapVersion = VERSION_UNKNOWN;
    // remove the starting and trailing " from the SOAP Action
    if ((soapActionHeader != null) 
            && soapActionHeader.length() > 0 
            && soapActionHeader.charAt(0) == '\"'
            && soapActionHeader.endsWith("\"")) {
        soapActionHeader = soapActionHeader.substring(1, soapActionHeader.length() - 1);
    }

    // fill up the Message Contexts
    msgContext.setSoapAction(soapActionHeader);
    msgContext.setTo(new EndpointReference(requestURI));
    msgContext.setServerSide(true);

    // get the type of char encoding
    String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
    if (charSetEnc == null) {
        charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
    }
    msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);

    if (contentType != null) {
        if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
            soapVersion = VERSION_SOAP12;
            TransportUtils.processContentTypeForAction(contentType, msgContext);
        } else if (contentType
                .indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
            soapVersion = VERSION_SOAP11;
        } else if (isRESTRequest(contentType)) {
            // If REST, construct a SOAP11 envelope to hold the rest message and
            // indicate that this is a REST message.
            soapVersion = VERSION_SOAP11;
            msgContext.setDoingREST(true);
        }
        if (soapVersion == VERSION_SOAP11) {
            // TODO Keith : Do we need this anymore
            // Deployment configuration parameter
        	Parameter disableREST = msgContext
                    .getParameter(Constants.Configuration.DISABLE_REST);
        	if (soapActionHeader == null && disableREST != null) {
        		if (Constants.VALUE_FALSE.equals(disableREST.getValue())) {
                    // If the content Type is text/xml (BTW which is the
                    // SOAP 1.1 Content type ) and the SOAP Action is
                    // absent it is rest !!
                    msgContext.setDoingREST(true);
                }
            }
        }
    }
    return soapVersion;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:56,代码来源:HTTPTransportUtils.java

示例14: testValidateActionFlag

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testValidateActionFlag() throws Exception {
    MessageContext mc = new MessageContext();

    Map<Pattern, AxisOperation> httpLocationTableForResource = new TreeMap<Pattern, AxisOperation>(
            new Comparator<Pattern>() {
                public int compare(Pattern o1, Pattern o2) {
                    return (-1 * o1.pattern().compareTo(o2.pattern()));
                }
            });
    AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
    String method1 = "GET";
    String httpLocation1 = "student";
    AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
    String method2 = "GET";
    String httpLocation2 = "student/{stuId}";

    Pattern httpLocationPattern1 = WSDLUtil.getConstantFromHTTPLocationForResource(httpLocation1, method1);
    Pattern httpLocationPattern2 = WSDLUtil.getConstantFromHTTPLocationForResource(httpLocation2, method2);
    httpLocationTableForResource.put(httpLocationPattern1, operation1);
    httpLocationTableForResource.put(httpLocationPattern2, operation2);

    // set request endpoint
    mc.setTo(new EndpointReference("/services/StudentsService/student?stuId=101"));
    //set HTTP method
    mc.setProperty(HTTPConstants.HTTP_METHOD, method1);

    AxisService axisService = new AxisService();
    axisService.setName("StudentsService");
    AxisEndpoint endpoint = new AxisEndpoint();
    AxisBinding binding = new AxisBinding();
    // set the httpLocationTable
    binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
    endpoint.setBinding(binding);
    mc.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME, endpoint);
    mc.setAxisService(axisService);

    HTTPLocationBasedDispatcher dispatcher = new HTTPLocationBasedDispatcher();
    // find correct operation for endpoint and it should equal to operation1
    AxisOperation resultOp = dispatcher.findOperation(axisService, mc);
    Assert.assertEquals(operation1, resultOp);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:42,代码来源:HTTPLocationBasedDispatcherTest.java

示例15: testFindService

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testFindService() throws AxisFault {
    MessageContext messageContext;

    //Global services
    AxisService as1 = new AxisService("Service1");
    as1.addEndpoint("Service1Endpoint", new AxisEndpoint());

    //Hierarchical Services
    AxisService as2 = new AxisService("foo/bar/Version");
    AxisService as3 = new AxisService("foo/bar/1.0.1/Echo");
    as2.addEndpoint("VersionEndpoint", new AxisEndpoint());
    as3.addEndpoint("EchoEndpoint", new AxisEndpoint());


    AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
    AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
    as1.addOperation(operation1);
    as1.addOperation(operation2);

    AxisOperation operation3 = new InOnlyAxisOperation(new QName("getVersion"));
    AxisOperation operation4 = new InOnlyAxisOperation(new QName("echo"));
    as2.addOperation(operation3);
    as3.addOperation(operation4);

    ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
    AxisConfiguration ac = cc.getAxisConfiguration();
    ac.addService(as1);
    ac.addService(as2);
    ac.addService(as3);

    RequestURIBasedOperationDispatcher ruisd = new RequestURIBasedOperationDispatcher();

    /**
     * Tests for global services
     */
    messageContext = cc.createMessageContext();
    messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
            "/axis2/services/Service1/operation2"));
    messageContext.setAxisService(as1);
    ruisd.invoke(messageContext);
    assertEquals(operation2, messageContext.getAxisOperation());

    messageContext = cc.createMessageContext();
    messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
            "/axis2/services/Service1.Service1Endpoint/operation2"));
    messageContext.setAxisService(as1);
    ruisd.invoke(messageContext);
    assertEquals(operation2, messageContext.getAxisOperation());

    /**
     * Tests for hierarchical services
     */
    messageContext = cc.createMessageContext();
    messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
            "/axis2/services/foo/bar/Version/getVersion"));
    messageContext.setAxisService(as2);
    ruisd.invoke(messageContext);
    assertEquals(operation3, messageContext.getAxisOperation());

    messageContext = cc.createMessageContext();
    messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
            "/axis2/services/foo/bar/Version.VersionEndpoint/getVersion"));
    messageContext.setAxisService(as2);
    ruisd.invoke(messageContext);
    assertEquals(operation3, messageContext.getAxisOperation());


    messageContext = cc.createMessageContext();
    messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
            "/axis2/services/foo/bar/1.0.1/Echo/echo"));
    messageContext.setAxisService(as3);
    ruisd.invoke(messageContext);
    assertEquals(operation4, messageContext.getAxisOperation());

    messageContext = cc.createMessageContext();
    messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
            "/axis2/services/foo/bar/1.0.1/Echo.EchoEndpoint/echo"));
    messageContext.setAxisService(as3);
    ruisd.invoke(messageContext);
    assertEquals(operation4, messageContext.getAxisOperation());
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:82,代码来源:RequestURIBasedOperationDispatcherTest.java


注:本文中的org.apache.axis2.context.MessageContext.setTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。