Search in sources :

Example 51 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class HTTPTransportUtils method initializeMessageContext.

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;
}
Also used : Parameter(org.apache.axis2.description.Parameter) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 52 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class AxisServlet method createMessageContext.

/**
 * @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);
    ServletContext context = getServletContext();
    if (context != null) {
        msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT, context);
    }
    // setting the RequestResponseTransport object
    msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL, new ServletRequestResponseTransport());
    return msgContext;
}
Also used : ServletContext(javax.servlet.ServletContext) MessageContext(org.apache.axis2.context.MessageContext) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 53 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class ServiceContext method readExternal.

/**
 * Restore the contents of the object that was previously saved.
 * <p/>
 * NOTE: The field data must read back in the same order and type
 * as it was written.  Some data will need to be validated when
 * resurrected.
 *
 * @param in The stream to read the object contents from
 * @throws IOException
 * @throws ClassNotFoundException
 */
public void readExternal(ObjectInput inObject) throws IOException, ClassNotFoundException {
    SafeObjectInputStream in = SafeObjectInputStream.install(inObject);
    // set the flag to indicate that the message context is being
    // reconstituted and will need to have certain object references
    // to be reconciled with the current engine setup
    needsToBeReconciled = true;
    // trace point
    if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
        log.trace(myClassName + ":readExternal():  BEGIN  bytes available in stream [" + in.available() + "]  ");
    }
    // ---------------------------------------------------------
    // object level identifiers
    // ---------------------------------------------------------
    // serialization version ID
    long suid = in.readLong();
    // revision ID
    int revID = in.readInt();
    // make sure the object data is in a version we can handle
    if (suid != serialVersionUID) {
        throw new ClassNotFoundException(ExternalizeConstants.UNSUPPORTED_SUID);
    }
    // make sure the object data is in a revision level we can handle
    if (revID != REVISION_2) {
        throw new ClassNotFoundException(ExternalizeConstants.UNSUPPORTED_REVID);
    }
    // ---------------------------------------------------------
    // various simple fields
    // ---------------------------------------------------------
    long time = in.readLong();
    setLastTouchedTime(time);
    cachingOperationContext = in.readBoolean();
    logCorrelationIDString = (String) in.readObject();
    // trace point
    if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
        log.trace(myClassName + ":readExternal():  reading input stream for [" + getLogCorrelationIDString() + "]  ");
    }
    // EndpointReference targetEPR
    targetEPR = (EndpointReference) in.readObject();
    // EndpointReference myEPR
    myEPR = (EndpointReference) in.readObject();
    // ---------------------------------------------------------
    // properties
    // ---------------------------------------------------------
    properties = in.readMap(new HashMap());
    // ---------------------------------------------------------
    // AxisService
    // ---------------------------------------------------------
    // axisService is not usable until the meta data has been reconciled
    metaAxisService = (MetaDataEntry) in.readObject();
    // ---------------------------------------------------------
    // parent
    // ---------------------------------------------------------
    // ServiceGroupContext is not usable until it has been activated
    metaParent = (ServiceGroupContext) in.readObject();
    // ---------------------------------------------------------
    // other
    // ---------------------------------------------------------
    // currently not saving this object
    lastOperationContext = null;
// ---------------------------------------------------------
// done
// ---------------------------------------------------------
}
Also used : SafeObjectInputStream(org.apache.axis2.context.externalize.SafeObjectInputStream) HashMap(java.util.HashMap)

Example 54 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class ServiceContext method getMyEPR.

/**
 * To get the ERP for a given service , if the transport is present and not
 * running then it will add as a listener to ListenerManager , there it will
 * init that and start the listener , and finally ask the EPR from transport
 * for a given service
 *
 * @param transport : Name of the transport
 * @return
 * @throws AxisFault
 */
public EndpointReference getMyEPR(String transport) throws AxisFault {
    axisService.isEnableAllTransports();
    ConfigurationContext configctx = this.configContext;
    if (configctx != null) {
        ListenerManager lm = configctx.getListenerManager();
        if (!lm.isListenerRunning(transport)) {
            TransportInDescription trsin = configctx.getAxisConfiguration().getTransportIn(transport);
            if (trsin != null) {
                lm.addListener(trsin, false);
            } else {
                throw new AxisFault(Messages.getMessage("transportnotfound", transport));
            }
        }
        if (!lm.isStopped()) {
            return lm.getEPRforService(axisService.getName(), null, transport);
        }
    }
    return null;
}
Also used : AxisFault(org.apache.axis2.AxisFault) TransportInDescription(org.apache.axis2.description.TransportInDescription) ListenerManager(org.apache.axis2.engine.ListenerManager)

Example 55 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class LocalTransportReceiver method processMessage.

public void processMessage(MessageContext inMessageContext, InputStream in, OutputStream response) throws AxisFault {
    if (this.confContext == null) {
        this.confContext = inMessageContext.getConfigurationContext();
    }
    this.inMessageContext = inMessageContext;
    EndpointReference to = inMessageContext.getTo();
    String action = inMessageContext.getOptions().getAction();
    processMessage(in, to, action, response);
}
Also used : EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)261 Options (org.apache.axis2.client.Options)99 OMElement (org.apache.axiom.om.OMElement)67 AxisFault (org.apache.axis2.AxisFault)66 MessageContext (org.apache.axis2.context.MessageContext)58 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)57 ServiceClient (org.apache.axis2.client.ServiceClient)54 QName (javax.xml.namespace.QName)40 ArrayList (java.util.ArrayList)37 AxisService (org.apache.axis2.description.AxisService)28 Map (java.util.Map)25 MessageContext (org.apache.synapse.MessageContext)25 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)25 Test (org.junit.Test)20 IOException (java.io.IOException)19 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)18 RelatesTo (org.apache.axis2.addressing.RelatesTo)18 URL (java.net.URL)17 SOAPFactory (org.apache.axiom.soap.SOAPFactory)17 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)17