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


Java MessageContext.getOptions方法代码示例

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


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

示例1: setMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * creating the message context of the soap message
 *
 * @param addUrl
 * @param trpUrl
 *  @param action
 */
private void setMessageContext(String addUrl, String trpUrl, String action) {
    outMsgCtx = new MessageContext();
    //assigning message context’s option object into instance variable
    Options options = outMsgCtx.getOptions();
    //setting properties into option
    if (trpUrl != null && !"null".equals(trpUrl)) {
        options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
    }
    if (addUrl != null && !"null".equals(addUrl)) {
        options.setTo(new EndpointReference(addUrl));
    }
    if(action != null && !"null".equals(action)) {
        options.setAction(action);
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:23,代码来源:AxisOperationClient.java

示例2: doProcessing

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Override
protected InvocationResponse doProcessing(final MessageContext mc) throws Exception {
    // Get current set of options
    final Options options = mc.getOptions();

    if (isInFlow(RESPONDER)) {
        // Acting as server, add HTTP Server header. Due to a bug in Axis we can't use the MC HTTPConstants.SERVER
        // Option and must set a response parameter directly
        final AxisHttpResponse resp = (AxisHttpResponse) mc.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO);
        resp.setHeader("Server", HTTP_HDR_VALUE);
    } else
        // Acting as client. add HTTP User-Agent header
        options.setProperty(HTTPConstants.USER_AGENT, HTTP_HDR_VALUE);

    return InvocationResponse.CONTINUE;
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:17,代码来源:HTTPProductIdentifier.java

示例3: getConnectionDetailsFromClientOptions

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Extract connection details from client options
 * @param serverCredentials
 * @param msgContext
 */
   private void getConnectionDetailsFromClientOptions(MessageContext msgContext){
   	Options clientOptions = msgContext.getOptions();

	if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME) != null){
		serverCredentials.setAccountName((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME));
	}
	if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_PASSWORD) != null){
		serverCredentials.setPassword((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_PASSWORD));
	}
	if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_URL) != null){
		serverCredentials.setServerUrl((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_URL));
	}
	if (clientOptions.getProperty(XMPPConstants.XMPP_SERVER_TYPE) != null){
		serverCredentials.setServerType((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_TYPE));
	}		
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:22,代码来源:XMPPSender.java

示例4: testDoProcessingForInitiator

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingForInitiator() throws Exception {
    System.out.println("[testDoProcessingForInitiator]");
    MessageContext mc = new MessageContext();
    mc.setFLOW(MessageContext.OUT_FLOW);
    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertNotNull(invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    Options options = mc.getOptions();
    assertNotNull(options.getProperty(HTTPConstants.USER_AGENT));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:15,代码来源:HTTPProductIdentifierTest.java

示例5: extractAddressingInformationFromHeaders

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected Options extractAddressingInformationFromHeaders(RolePlayer rolePlayer)
        throws Exception {
    String testfile = "valid-messages/" + versionDirectory + "/" + testFileName;

    MessageContext mc = new MessageContext();
    final ConfigurationContext context =
            ConfigurationContextFactory.createEmptyConfigurationContext();
    mc.setConfigurationContext(context);
    if (rolePlayer != null) {
        mc.getConfigurationContext().getAxisConfiguration()
                .addParameter(Constants.SOAP_ROLE_PLAYER_PARAMETER, rolePlayer);
    }
    basicExtractAddressingInformationFromHeaders(testfile, mc);

    Options options = mc.getOptions();

    if (options == null) {
        fail("Addressing Information Headers have not been retrieved properly");
    }
    assertEquals("action header is not correct", action, options.getAction());
    assertActionHasExtensibilityAttribute(mc);
    assertEquals("message id header is not correct",
                 options.getMessageId().trim(),
                 messageID.trim());
    assertMessageIDHasExtensibilityAttribute(mc);

    assertFullFromEPR(options.getFrom());
    assertFullFaultEPR(options.getFaultTo());
    assertFullReplyToEPR(options.getReplyTo());

    assertRelationships(options);

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

示例6: testMessageWithOmittedHeaders

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected Options testMessageWithOmittedHeaders(String testName) throws Exception {
    String testfile =
            "omitted-header-messages/" + versionDirectory + "/" + testName + "Message.xml";

    MessageContext mc = new MessageContext();
    ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
    mc.setConfigurationContext(cc);
    basicExtractAddressingInformationFromHeaders(testfile, mc);

    return mc.getOptions();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:12,代码来源:AddressingInHandlerTestBase.java

示例7: extractActionInformation

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void extractActionInformation(SOAPHeaderBlock soapHeaderBlock,
                                      MessageContext messageContext)
        throws AxisFault {
    Options messageContextOptions = messageContext.getOptions();
    String soapAction = messageContextOptions.getAction();
    String wsaAction = soapHeaderBlock.getText();

    if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
        log.trace("extractActionInformation: HTTP soapAction or action ='" + soapAction + 
                "' wsa:Action='" + wsaAction + "'");
    }

    // Need to validate that the content of the wsa:Action header is not null or whitespace
    if ((wsaAction == null) || "".equals(wsaAction.trim())) {
        if (log.isDebugEnabled()) {
            log.debug("The wsa:Action header is present but its contents are empty.  This violates " +
                    "rules in the WS-A specification.  The SOAP node that sent this message must be changed.");
        }
        AddressingFaultsHelper.triggerActionNotSupportedFault(messageContext, wsaAction);
    }

    // The isServerSide check is because the underlying Options object is
    // shared between request and response MessageContexts for Sync
    // invocations. If the soapAction is set outbound and a wsa:Action is
    // received on the response they will differ (because there is no
    // SOAPAction header on an HTTP response). In this case we should not
    // check that soapAction==wsa:Action
    if (soapAction != null && !"".equals(soapAction) && messageContext.isServerSide()) {
        if (!soapAction.equals(wsaAction)) {
            if (log.isDebugEnabled()) {
                log.debug("The wsa:Action header is (" + wsaAction + ") which conflicts with the HTTP soapAction or action " +
                        "(" + soapAction + ").  This is a violation of the WS-A specification.  The SOAP node that sent this message " +
                        " must be changed.");
            }
            AddressingFaultsHelper.triggerActionMismatchFault(messageContext, soapAction, wsaAction);
        }
    } else {
        messageContextOptions.setAction(wsaAction);
    }

    ArrayList attributes = extractAttributesFromSOAPHeaderBlock(soapHeaderBlock);
    if (attributes != null) {
        messageContext.setProperty(AddressingConstants.ACTION_ATTRIBUTES, attributes);
    }

    soapHeaderBlock.setProcessed();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:48,代码来源:AddressingInHandler.java

示例8: populateCommonProperties

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Method used to copy all the common properties
 *
 * @param msgContext       - The messageContext of the request message
 * @param url              - The target URL
 * @param httpMethod       - The http method used to send the request
 * @param httpClient       - The httpclient used to send the request
 * @param soapActionString - The soap action atring of the request message
 * @return MessageFormatter - The messageFormatter for the relavent request message
 * @throws AxisFault - Thrown in case an exception occurs
 */
protected MessageFormatter populateCommonProperties(MessageContext msgContext, URL url,
                                                  HttpMethodBase httpMethod,
                                                  HttpClient httpClient,
                                                  String soapActionString)
        throws AxisFault {

    if (isAuthenticationEnabled(msgContext)) {
        httpMethod.setDoAuthentication(true);
    }

    MessageFormatter messageFormatter = MessageProcessorSelector
                    .getMessageFormatter(msgContext);

    url = messageFormatter.getTargetAddress(msgContext, format, url);

    httpMethod.setPath(url.getPath());

    httpMethod.setQueryString(url.getQuery());

    // If adding the Content-Type header from the message formatter needs to be skipped
    if (Boolean.parseBoolean((String)msgContext.getProperty(HTTPConstants.NO_DEFAULT_CONTENT_TYPE))) {
        // Check whether message context already has the Content-Type header,
        // if so use that as the Content-Type header
        Object transportHeadersObj = msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
        if (transportHeadersObj != null && transportHeadersObj instanceof Map) {
            Map transportHeaders = (Map) transportHeadersObj;
            Object headerContentType = transportHeaders.get(HTTPConstants.HEADER_CONTENT_TYPE);
            if (headerContentType != null) {
                httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, headerContentType.toString());
            }
        }
        // If NO_DEFAULT_CONTENT_TYPE is set to true and the Content-Type header is not present
        // in the message context, backend will receive a request without a Content-Type header
    } else {
        httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
                messageFormatter.getContentType(msgContext, format, soapActionString));
    }

    httpMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());

    if (msgContext.getOptions() != null && msgContext.getOptions().isManageSession()) {
        // setting the cookie in the out path
        Object cookieString = msgContext.getProperty(HTTPConstants.COOKIE_STRING);

        if (cookieString != null) {
            StringBuffer buffer = new StringBuffer();
            buffer.append(cookieString);
            httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString());
        }
    }

    if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
        httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
    }
    return messageFormatter;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:68,代码来源:AbstractHTTPSender.java


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