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


Java MessageContext.setDoingREST方法代码示例

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


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

示例1: getOMOutputFormat

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Get the OMOutput format for the given message
 * @param msgContext the axis message context
 * @return the OMOutput format to be used
 */
public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) {

    OMOutputFormat format = new OMOutputFormat();
    msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext));
    msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext));
    msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext));
    format.setSOAP11(msgContext.isSOAP11());
    format.setDoOptimize(msgContext.isDoingMTOM());
    format.setDoingSWA(msgContext.isDoingSwA());

    format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext));
    Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY);
    if (mimeBoundaryProperty != null) {
        format.setMimeBoundary((String) mimeBoundaryProperty);
    }
    return format;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:23,代码来源:BaseUtils.java

示例2: isDoingREST

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static boolean isDoingREST(MessageContext msgContext) {
    boolean enableREST = false;

    // check whether isDoingRest is already true in the message context
    if (msgContext.isDoingREST()) {
        return true;
    }

    Object enableRESTProperty = msgContext.getProperty(Constants.Configuration.ENABLE_REST);
    if (enableRESTProperty != null) {
        enableREST = JavaUtils.isTrueExplicitly(enableRESTProperty);
    }

    msgContext.setDoingREST(enableREST);

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

示例3: processDocument

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement processDocument(InputStream inputStream, String contentType,
                                 MessageContext msgContext)
        throws AxisFault {
    msgContext.setDoingREST(true);
    
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("", "");
    byte[] bytes;
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
        BufferUtils.inputStream2OutputStream(inputStream, baos);
        baos.flush();
        bytes = baos.toByteArray();
    } catch (IOException e) {
        throw AxisFault.makeFault(e);
    }
    ByteArrayDataSourceEx ds = new ByteArrayDataSourceEx(bytes, contentType);
    return factory.createOMElement(ds, "dummy", ns);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:DataSourceBuilder.java

示例4: send

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Synchronously send the request and receive a response. This relies on the transport correctly connecting the
 * response InputStream!
 *
 * @param msgContext the request MessageContext to send.
 * @return Returns MessageContext.
 * @throws AxisFault Sends the message using a two way transport and waits for a response
 */
protected MessageContext send(final MessageContext msgContext) throws AxisFault {

// create the responseMessageContext
    final MessageContext responseMessageContext
            = msgContext.getConfigurationContext().createMessageContext();

    responseMessageContext.setServerSide(false);
    responseMessageContext.setOperationContext(msgContext.getOperationContext());
    responseMessageContext.setOptions(new Options(options));
    responseMessageContext.setMessageID(msgContext.getMessageID());
    addMessageContext(responseMessageContext);
    responseMessageContext.setServiceContext(msgContext.getServiceContext());
    responseMessageContext.setAxisMessage(
            axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));

    //sending the message
    AxisEngine.send(msgContext);

    responseMessageContext.setDoingREST(msgContext.isDoingREST());

// Copy RESPONSE properties which the transport set onto the request message context when it processed
    // the incoming response recieved in reply to an outgoing request.
    responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
            msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
    responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
            msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));

    responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
            .getProperty(MessageContext.TRANSPORT_IN));
    responseMessageContext.setTransportIn(msgContext.getTransportIn());
    responseMessageContext.setTransportOut(msgContext.getTransportOut());
    handleResponse(responseMessageContext);
    return responseMessageContext;
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:43,代码来源:OutOptInAxisOperation.java

示例5: 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

示例6: send

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Synchronously send the request and receive a response.  This relies on the transport
 * correctly connecting the response InputStream!
 *
 * @param msgContext the request MessageContext to send.
 * @return Returns MessageContext.
 * @throws AxisFault Sends the message using a two way transport and waits for a response
 */
protected MessageContext send(MessageContext msgContext) throws AxisFault {

    // create the responseMessageContext

    MessageContext responseMessageContext =
            msgContext.getConfigurationContext().createMessageContext();

    responseMessageContext.setServerSide(false);
    responseMessageContext.setOperationContext(msgContext.getOperationContext());
    responseMessageContext.setOptions(new Options(options));
    responseMessageContext.setMessageID(msgContext.getMessageID());
    addMessageContext(responseMessageContext);
    responseMessageContext.setServiceContext(msgContext.getServiceContext());
    responseMessageContext.setAxisMessage(
            axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));

    //sending the message
    AxisEngine.send(msgContext);

    responseMessageContext.setDoingREST(msgContext.isDoingREST());

    // Copy RESPONSE properties which the transport set onto the request message context when it processed
    // the incoming response recieved in reply to an outgoing request.
    responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
            msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
    responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
            msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));

    responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
            .getProperty(MessageContext.TRANSPORT_IN));
    responseMessageContext.setTransportIn(msgContext.getTransportIn());
    responseMessageContext.setTransportOut(msgContext.getTransportOut());
    handleResponse(responseMessageContext);
    return responseMessageContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:44,代码来源:OutInAxisOperation.java

示例7: putMessageOnMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Put the JAX-WS Message onto the Axis2 MessageContext
 *
 * @param message    JAX-WS Message
 * @param msgContext Axis2MessageContext
 */
public static void putMessageOnMessageContext(Message message, MessageContext msgContext)
        throws AxisFault, WebServiceException {
    // Put the XML message on the Axis 2 Message Context
    SOAPEnvelope envelope = (SOAPEnvelope)message.getAsOMElement();
    msgContext.setEnvelope(envelope);

    // Put the Headers onto the MessageContext
    Map headerMap = message.getMimeHeaders();
    msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
    msgContext.setProperty(HTTPConstants.HTTP_HEADERS, headerMap);

    if (message.getProtocol() == Protocol.rest) {
        msgContext.setDoingREST(true);
        msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, HTTPConstants.MEDIA_TYPE_APPLICATION_XML);
    }
    
    // Detect if a SOAPAction header is set as a Mime header in request message
    String soapAction = (String) headerMap.get("SOAPAction");
    if (soapAction != null) {
    	if (log.isDebugEnabled()) {
    		log.debug("Found SOAPAction as Mime header: " + soapAction);
    	}
    	// Set on MessageContext and it will be written out in request
    	msgContext.setSoapAction(soapAction);
    }
    
    // Make sure the the JAX-WS AttachmentAdapter is correctly installed
    // So that any user attachments provide are moved to the Axiom Attachments
    // Map
    if (message.getMessageContext() != null) {
        AttachmentsAdapter.install(message.getMessageContext());
        TransportHeadersAdapter.install(message.getMessageContext());
        SOAPHeadersAdapter.install(message.getMessageContext());
    }
    
    if (message.isDoingSWA()) {
        // Enable SWA on the Axis2 MessageContext
        msgContext.setDoingSwA(true);
        msgContext.setProperty(Configuration.ENABLE_SWA, "true");
    }

    // Enable MTOM Attachments 
    if (message.isMTOMEnabled()) {
        // Enable MTOM on the Axis2 MessageContext
        msgContext.setProperty(Configuration.ENABLE_MTOM, "true");
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:54,代码来源:MessageUtils.java

示例8: 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

示例9: createResponseMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Creates a new 'response' message context based on a 'request' message context
 * Only deals with properties/fields that are the same for both 'normal' and fault responses.
 *
 * @param inMessageContext context for which the response will be created
 * @return response message context for the given in message context
 * @throws org.apache.axis2.AxisFault error in creating the response message context
 */
private static MessageContext createResponseMessageContext(MessageContext inMessageContext)
        throws AxisFault {
    MessageContext newmsgCtx =
            inMessageContext.getConfigurationContext().createMessageContext();

    newmsgCtx.setSessionContext(inMessageContext.getSessionContext());
    newmsgCtx.setTransportIn(inMessageContext.getTransportIn());
    newmsgCtx.setTransportOut(inMessageContext.getTransportOut());
    newmsgCtx.setServerSide(inMessageContext.isServerSide());
    newmsgCtx.setProperty(MessageContext.IN_MESSAGE_CONTEXT, inMessageContext);

    // TODO: Should this be specifying (or defaulting to) the "response" relationshipType??
    newmsgCtx.addRelatesTo(new RelatesTo(inMessageContext.getOptions().getMessageId()));

    newmsgCtx.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                          inMessageContext.getProperty(
                                  AddressingConstants.WS_ADDRESSING_VERSION));
    newmsgCtx.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
                          inMessageContext.getProperty(
                                  AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));

    newmsgCtx.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
                          inMessageContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME));
    newmsgCtx.setProperty(Constants.AXIS_BINDING_OPERATION,
                          inMessageContext.getProperty(Constants.AXIS_BINDING_OPERATION));

    // Setting the charater set encoding
    newmsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                          inMessageContext.getProperty(
                                  Constants.Configuration.CHARACTER_SET_ENCODING));
    //Setting the message type property
    newmsgCtx.setProperty(Constants.Configuration.MESSAGE_TYPE,
                          inMessageContext.getProperty(Constants.Configuration.MESSAGE_TYPE));
    newmsgCtx.setDoingREST(inMessageContext.isDoingREST());

    newmsgCtx.setOperationContext(inMessageContext.getOperationContext());

    newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,
                          inMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
    newmsgCtx.setProperty(Constants.OUT_TRANSPORT_INFO,
                          inMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));

    handleCorrelationID(inMessageContext,newmsgCtx);
    return newmsgCtx;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:54,代码来源:MessageContextBuilder.java


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