Examples of OperationClient


Examples of org.apache.axis2.client.OperationClient

        super(serviceClient, wsdlOperationName, options, soapFactory, policyHandlerList, wsBinding);
    }

    @Override
    protected Object invokeTarget(Message msg) throws AxisFault {
        OperationClient operationClient = createOperationClient(msg);

        // ensure connections are tracked so that they can be closed by the reference binding
        MessageContext requestMC = operationClient.getMessageContext("Out");
        //requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
        Options opt = requestMC.getOptions();
        opt.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
        opt.setUseSeparateListener(true);
        opt.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,Boolean.TRUE);       

        operationClient.execute(false);

        // REVIEW it seems ok to return null
        return null;
    }
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

                                    configuration.getAxis2Xml());

            ServiceClient sender = new ServiceClient(configContext, null);

            sender.setOptions(options);
            OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

            MessageContext mc = new MessageContext();

            log.info("Sending file : " + fileName + " as SwA");
            FileDataSource fileDataSource = new FileDataSource(new File(fileName));
            DataHandler dataHandler = new DataHandler(fileDataSource);
            String attachmentID = mc.addAttachment(dataHandler);


            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
            SOAPEnvelope env = factory.getDefaultEnvelope();
            OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
            OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns);
            OMElement request = factory.createOMElement("request", ns);
            OMElement imageId = factory.createOMElement("imageId", ns);
            imageId.setText(attachmentID);
            request.addChild(imageId);
            payload.addChild(request);
            env.getBody().addChild(payload);
            mc.setEnvelope(env);

            mepClient.addMessageContext(mc);
            mepClient.execute(true);
            MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

            SOAPBody body = response.getEnvelope().getBody();
            String imageContentId = body.
                    getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")).
                    getFirstChildWithName(new QName("http://services.samples", "response")).
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

            AxisOperation opdesc = new OutInAxisOperation();
            opdesc.setName(opName);
            //   AxisOperation opdesc = new AxisOperation(new QName("viewVersion"));
            ServiceClient serviceClient = new ServiceClient();
            serviceClient.setOptions(options);
            OperationClient opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
            opClient.addMessageContext(requestContext);
            opClient.setCallback(new ClientCallbackHandler(this.gui));
            opClient.execute(false);

        } catch (AxisFault e1) {
            e1.printStackTrace();
        }
    }
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

                String cookie = cookies[cookieNumber];
                if (httpSession) {
                    setSessionID(messageContext, cookie);
                }
                try {
                    OperationClient op = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
                    op.addMessageContext(messageContext);
                    op.execute(true);

                    MessageContext responseContext =
                            op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                    String receivedCookie = extractSessionID(responseContext);
                    String receivedSetCookie = getSetCookieHeader(responseContext);
                    if (httpSession) {

                        if (receivedSetCookie != null && !"".equals(receivedSetCookie)) {
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

                serviceClient.setOptions(options);
                MessageContext requetMessageContext = new MessageContext();
                requetMessageContext.setEnvelope(getRequestEnvelope(opStr, param1, param2,
                        serviceGroupContextId));

                OperationClient opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
                opClient.addMessageContext(requetMessageContext);
                opClient.setOptions(options);

                opClient.execute(true);

                SOAPEnvelope result = opClient.getMessageContext(
                        WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();

                printResult(result);

                if (serviceGroupContextId == null)
                    serviceGroupContextId = getServiceGroupContextId(result);


            } else if ("c".equalsIgnoreCase(option)) {
                if (serviceGroupContextId == null) {
                    System.out.println("Error: First operation must be a New one. Please select 'n'");
                    continue;
                }

                System.out.print("Enter parameter...");
                String paramStr = reader.readLine();
                int param = Integer.parseInt(paramStr);
                String opStr = null;
                if ("+".equals(operation)) {
                    opStr = "addPrevious";
                } else if ("-".equals(operation)) {
                    opStr = "substractPrevious";
                } else if ("*".equals(operation)) {
                    opStr = "multiplyPrevious";
                }

                System.out.println("Invoking...");


                ServiceClient serviceClient = new ServiceClient();
                serviceClient.setOptions(options);
                MessageContext requetMessageContext = new MessageContext();
                requetMessageContext.setEnvelope(getPreviousRequestEnvelope(opStr, param,
                        serviceGroupContextId));

                OperationClient opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
                opClient.addMessageContext(requetMessageContext);
                opClient.setOptions(options);

                opClient.execute(true);

                SOAPEnvelope result = opClient.getMessageContext(
                        WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();

                printResult(result);

            }
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

                        OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory();
                fac.createSOAPHeader(axisOutMsgCtx.getEnvelope());
            }
        }

        OperationClient mepClient = axisAnonymousOperation.createClient(serviceCtx, clientOptions);
        mepClient.addMessageContext(axisOutMsgCtx);
        axisOutMsgCtx.setAxisMessage(
                axisAnonymousOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));

        // set the SEND_TIMEOUT for transport sender
        if (endpoint != null && endpoint.getTimeoutDuration() > 0) {
            axisOutMsgCtx.setProperty(SynapseConstants.SEND_TIMEOUT, endpoint.getTimeoutDuration());
        }

        if (!outOnlyMessage) {
            // always set a callback as we decide if the send it blocking or non blocking within
            // the MEP client. This does not cause an overhead, as we simply create a 'holder'
            // object with a reference to the outgoing synapse message context
            // synapseOutMessageContext
            AsyncCallback callback = new AsyncCallback(synapseOutMessageContext);
            if (endpoint != null) {
                // set the timeout time and the timeout action to the callback, so that the
                // TimeoutHandler can detect timed out callbacks and take approprite action.
                callback.setTimeOutOn(System.currentTimeMillis() + endpoint.getTimeoutDuration());
                callback.setTimeOutAction(endpoint.getTimeoutAction());
            } else {
                callback.setTimeOutOn(System.currentTimeMillis());
            }
            mepClient.setCallback(callback);
        }

        // this is a temporary fix for converting messages from HTTP 1.1 chunking to HTTP 1.0.
        // Without this HTTP transport can block & become unresponsive because we are streaming
        // HTTP 1.1 messages and HTTP 1.0 require the whole message to caculate the content length
        if (originalInMsgCtx.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0)) {
            synapseOutMessageContext.getEnvelope().toString();
        }

        // with the nio transport, this causes the listener not to write a 202
        // Accepted response, as this implies that Synapse does not yet know if
        // a 202 or 200 response would be written back.
        originalInMsgCtx.getOperationContext().setProperty(
                org.apache.axis2.Constants.RESPONSE_WRITTEN, "SKIP");

        // if the transport out is explicitly set use it
        Object o = originalInMsgCtx.getProperty("TRANSPORT_OUT_DESCRIPTION");
        if (o != null && o instanceof TransportOutDescription) {
            axisOutMsgCtx.setTransportOut((TransportOutDescription) o);
            clientOptions.setTransportOut((TransportOutDescription) o);
            clientOptions.setProperty("TRANSPORT_OUT_DESCRIPTION", o);
        }

        mepClient.execute(true);
        if (wsRMEnabled) {
            Object rm11 = clientOptions.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
            if ((rm11 != null) && rm11.equals(Sandesha2Constants.SPEC_VERSIONS.v1_1)){
                ServiceClient serviceClient = new ServiceClient(
                        axisOutMsgCtx.getConfigurationContext(), axisOutMsgCtx.getAxisService());
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

        return msg;
    }

    protected Object invokeTarget(Message msg) throws AxisFault {
        final OperationClient operationClient = createOperationClient(msg);

        // ensure connections are tracked so that they can be closed by the reference binding
        MessageContext requestMC = operationClient.getMessageContext("Out");
        requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
        requestMC.getOptions().setTimeOutInMilliSeconds(240000L);

        /*
        for ( PolicyHandler policyHandler : policyHandlerList ) {
            policyHandler.beforeInvoke(msg, requestMC, operationClient);
        }
        */
       
        // set policy specified headers
        for (Axis2HeaderPolicy policy : axis2HeaderPolicies){
            Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, policy.getHeaderName());
        }
       
        if (basicAuthenticationPolicy != null) {
            Axis2BindingBasicAuthenticationConfigurator.setOperationOptions(operationClient, msg, basicAuthenticationPolicy);
        }
       
        if (axis2TokenAuthenticationPolicy != null) {
            Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, axis2TokenAuthenticationPolicy.getTokenName());
        }
       
        // Allow privileged access to read properties. Requires PropertiesPermission read in
        // security policy.
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() throws AxisFault {
                    operationClient.execute(true);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            operationClient.complete(requestMC);
            throw (AxisFault)e.getException();
        }

        MessageContext responseMC = operationClient.getMessageContext("In");
       
        /*
        for ( PolicyHandler policyHandler : policyHandlerList ) {
            policyHandler.afterInvoke(msg, responseMC, operationClient);
        }
        */
       
        OMElement response = responseMC.getEnvelope().getBody().getFirstElement();

        // FIXME: [rfeng] We have to pay performance penalty to build the complete OM as the operationClient.complete() will
        // release the underlying HTTP connection.
        // Force the response to be populated, see https://issues.apache.org/jira/browse/TUSCANY-1541
        if (response != null) {
            response.build();
        }

        operationClient.complete(requestMC);

        return response;
    }
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

        }
        final MessageContext requestMC = new MessageContext();
        requestMC.setEnvelope(env);

        // Axis2 operationClients can not be shared so create a new one for each request
        final OperationClient operationClient = serviceClient.getServiceClient().createClient(wsdlOperationName);
        operationClient.setOptions(options);

        ReferenceParameters parameters = msg.getFrom().getReferenceParameters();

        // set callback endpoint and callback ID for WS-Addressing header
        EndpointReference fromEPR = null;
        org.apache.tuscany.sca.runtime.EndpointReference callbackEPR = parameters.getCallbackReference();
        if (callbackEPR != null) {
            fromEPR = new EndpointReference(callbackEPR.getBinding().getURI());
        }
        Object callbackID = parameters.getCallbackID();
        if (callbackID != null) {
            if (fromEPR == null) {
                fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
            }
            //FIXME: serialize callback ID to XML in case it is not a string
            fromEPR.addReferenceParameter(CALLBACK_ID_REFPARM_QN, callbackID.toString());
        }

        // set conversation ID for WS-Addressing header
        Object conversationId = parameters.getConversationID();
        if (conversationId != null) {
            if (fromEPR == null) {
                fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
            }
            //FIXME: serialize conversation ID to XML in case it is not a string
            fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId.toString());
        }

        // add WS-Addressing header
        //FIXME: is there any way to use the Axis2 addressing support for this?
        if (fromEPR != null) {
            SOAPEnvelope sev = requestMC.getEnvelope();
            SOAPHeader sh = sev.getHeader();
            OMElement epr =
                EndpointReferenceHelper.toOM(sev.getOMFactory(),
                                             fromEPR,
                                             QNAME_WSA_FROM,
                                             AddressingConstants.Final.WSA_NAMESPACE);
            sh.addChild(epr);
            requestMC.setFrom(fromEPR);
        }
       
        // Set any message headers required by policy
        // Get the header from the tuscany message
        // If its not already an OM convert it to OM
        // add it to the envelope header

        // if target endpoint was not specified when this invoker was created,
        // use dynamically specified target endpoint passed in on this call
        if (options.getTo() == null) {
            org.apache.tuscany.sca.runtime.EndpointReference ep = msg.getTo();
            if (ep != null) {
                requestMC.setTo(new EndpointReference(ep.getURI()));
            } else {
                throw new RuntimeException("Unable to determine destination endpoint");
            }
        } else {
            requestMC.setTo(new EndpointReference(options.getTo().getAddress()));
        }
       
        // Allow privileged access to read properties. Requires PropertiesPermission read in
        // security policy.
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() throws AxisFault {
                    operationClient.addMessageContext(requestMC);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            throw (AxisFault)e.getException();
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

        super(serviceClient, wsdlOperationName, options, soapFactory, wsBinding);
    }

    @Override
    protected Object invokeTarget(Message msg) throws AxisFault {
        OperationClient operationClient = createOperationClient(msg);

        // ensure connections are tracked so that they can be closed by the reference binding
        MessageContext requestMC = operationClient.getMessageContext("Out");
        //requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
        Options opt = requestMC.getOptions();
        opt.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
        opt.setUseSeparateListener(true);
        opt.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,Boolean.TRUE);       

        operationClient.execute(false);

        // REVIEW it seems ok to return null
        return null;
    }
View Full Code Here

Examples of org.apache.axis2.client.OperationClient

            ac.getService("__ANONYMOUS_SERVICE__")
                .getOperation(new QName("__OPERATION_OUT_IN__"));

        //Options class from Axis2 holds client side settings
        Options options = new Options();
        OperationClient mepClient =
            axisAnonymousOperation.createClient(sc, options);
        mepClient.addMessageContext(mc);
        mepClient.execute(true);
        MessageContext response = mepClient
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        response.setProperty(MessageContext.TRANSPORT_OUT,
            axisMsgCtx.getProperty(MessageContext.TRANSPORT_OUT));
        response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
            axisMsgCtx.getProperty(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.