• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OperationClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.axis2.client.OperationClient的典型用法代码示例。如果您正苦于以下问题:Java OperationClient类的具体用法?Java OperationClient怎么用?Java OperationClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OperationClient类属于org.apache.axis2.client包,在下文中一共展示了OperationClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: send

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
protected MessageContext send(ClientOptions options, AxisMessage message, QName operationQName,
            boolean block, String resultMessageLabel) throws Exception {
        
        OperationClient mepClient = serviceClient.createClient(operationQName);
        MessageContext mc = new MessageContext();
        mc.setProperty(Constants.Configuration.MESSAGE_TYPE, message.getMessageType());
        mc.setEnvelope(message.getEnvelope());
        Attachments attachments = message.getAttachments();
        if (attachments != null) {
            mc.setAttachmentMap(attachments);
            mc.setDoingSwA(true);
            mc.setProperty(Constants.Configuration.ENABLE_SWA, true);
        }
        for (AxisTestClientConfigurator configurator : configurators) {
            configurator.setupRequestMessageContext(mc);
        }
        mc.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, options.getCharset());
        mc.setServiceContext(serviceClient.getServiceContext());
        if (metrics != null) {
            mc.setProperty(BaseConstants.METRICS_COLLECTOR, metrics);
        }
        mepClient.addMessageContext(mc);
        mepClient.execute(block);
//        mepClient.complete(mc);
        return resultMessageLabel == null ? null : mepClient.getMessageContext(resultMessageLabel);
    }
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:27,代码来源:AxisTestClient.java


示例2: getResponse

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
private SOAPEnvelope getResponse(SOAPEnvelope inEnvelope) throws AxisFault {
    ConfigurationContext confctx = ConfigurationContextFactory.
            createConfigurationContextFromFileSystem(TestingUtils.prefixBaseDirectory("target/test-resources/integrationRepo"),
                                                     null);
    ServiceClient client = new ServiceClient(confctx, null);
    Options options = new Options();
    client.setOptions(options);
    options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    options.setTo(targetEPR);
    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    options.setExceptionToBeThrownOnSOAPFault(false);
    MessageContext msgctx = new MessageContext();
    msgctx.setEnvelope(inEnvelope);
    OperationClient opClient = client.createClient(ServiceClient.ANON_OUT_IN_OP);
    opClient.addMessageContext(msgctx);
    opClient.execute(true);
    return opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:FaultHandlingTest.java


示例3: getOperationClient

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
private static OperationClient getOperationClient(MessageContext partnerMessageContext,
                                                  ConfigurationContext clientConfigCtx)
        throws AxisFault {

    AxisService anonymousService =
            AnonymousServiceFactory.getAnonymousService(Constants.registrationService,
                    Constants.REGISTRATION_PORT,
                    clientConfigCtx.getAxisConfiguration(), Constants.HUMANTASK_COORDINATION_MODULE_NAME);

    anonymousService.getParent().addParameter("hiddenService", "true");
    ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
    ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);

    AxisOperation axisAnonymousOperation = anonymousService.getOperation(ServiceClient.ANON_OUT_IN_OP);

    Options clientOptions = cloneOptions(partnerMessageContext.getOptions());
    clientOptions.setExceptionToBeThrownOnSOAPFault(false);
    /* This value doesn't overrideend point config. */
    clientOptions.setTimeOutInMilliSeconds(60000);

    return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:23,代码来源:ServiceUtils.java


示例4: getOperationClient

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
private static OperationClient getOperationClient(ServiceInvocationContext partnerMessageContext,
                                                  ConfigurationContext clientConfigCtx)
        throws AxisFault {
    AxisService anonymousService =
            AnonymousServiceFactory.getAnonymousService(partnerMessageContext.getService(),
                    partnerMessageContext.getPort(),
                    clientConfigCtx.getAxisConfiguration(), partnerMessageContext.getCaller());
    anonymousService.engageModule(clientConfigCtx.getAxisConfiguration().getModule("UEPModule"));
    anonymousService.getParent().addParameter(
            "hiddenService", "true");
    ServiceGroupContext sgc = new ServiceGroupContext(
            clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
    ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);

    // get a reference to the DYNAMIC operation of the Anonymous Axis2 service
    AxisOperation axisAnonymousOperation = anonymousService.getOperation(
            partnerMessageContext.isTwoWay() ? ServiceClient.ANON_OUT_IN_OP :
                    ServiceClient.ANON_OUT_ONLY_OP);

    Options clientOptions = cloneOptions(partnerMessageContext.getInMessageContext().getOptions());
    clientOptions.setExceptionToBeThrownOnSOAPFault(false);
    /* This value doesn't overrideend point config. */
    clientOptions.setTimeOutInMilliSeconds(60000);

    return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:27,代码来源:AxisServiceUtils.java


示例5: getOperationClient

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public static OperationClient getOperationClient(BPELMessageContext partnerMessageContext,
                                                 ConfigurationContext clientConfigCtx)
        throws AxisFault {
    AxisService anonymousService =
            AnonymousServiceFactory.getAnonymousService(partnerMessageContext.getService(),
                    partnerMessageContext.getPort(),
                    clientConfigCtx.getAxisConfiguration(), partnerMessageContext.getCaller());
    anonymousService.engageModule(clientConfigCtx.getAxisConfiguration().getModule("UEPModule"));
    anonymousService.getParent().addParameter(
            BPELConstants.HIDDEN_SERVICE_PARAM, "true");
    ServiceGroupContext sgc = new ServiceGroupContext(
            clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
    ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);

    // get a reference to the DYNAMIC operation of the Anonymous Axis2 service
    AxisOperation axisAnonymousOperation = anonymousService.getOperation(
            partnerMessageContext.isTwoWay() ? ServiceClient.ANON_OUT_IN_OP :
                    ServiceClient.ANON_OUT_ONLY_OP);

    Options clientOptions = cloneOptions(partnerMessageContext.getInMessageContext().getOptions());
    clientOptions.setExceptionToBeThrownOnSOAPFault(false);
    /* This value doesn't overrideend point config. */
    clientOptions.setTimeOutInMilliSeconds(60000);

    return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:27,代码来源:AxisServiceUtils.java


示例6: createOperationClient

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
/**
 * Use the provided ServiceClient instance to create an OperationClient identified by the
 * operation QName provided.
 *
 * @param sc
 * @param operation
 * @return
 */
private OperationClient createOperationClient(ServiceClient sc, QName operation) {
    if (sc == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("ICCreateOpClientErr1"));
    }
    if (operation == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("ICCreateOpClientErr2"));
    }

    if (log.isDebugEnabled()) {
        log.debug("Creating OperationClient for operation: " + operation);
    }

    try {
        OperationClient client = sc.createClient(operation);
        return client;
    } catch (AxisFault e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:30,代码来源:AxisInvocationController.java


示例7: preExecute

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
/**
 * Called by execute(OperationClient) to perform pre-execute tasks.
 *
 * @param opClient
 * @param block      - Indicates if blocking or non-blocking execute
 * @param msgContext - Axis2 MessageContext
 */
private void preExecute(OperationClient opClient,
                        boolean block,
                        org.apache.axis2.context.MessageContext msgContext) throws AxisFault {
    // This assumes that we are on the ultimate execution thread

    //This has to be here so the ThreadContextMigrator can pick it up.
    msgContext.getOptions().setUseSeparateListener(opClient.getOptions().isUseSeparateListener());

    ThreadContextMigratorUtil
            .performMigrationToContext(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, msgContext);
    
    //Enable the ThreadContextMigrator to override UseSeparateListener
    opClient.getOptions().setUseSeparateListener(msgContext.getOptions().isUseSeparateListener());

    if (log.isDebugEnabled()) {
        log.debug("Start OperationClient.execute(" + block + ")");
        log.debug("UseSeparateListener: " + opClient.getOptions().isUseSeparateListener());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:AxisInvocationController.java


示例8: main

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        ServiceClient serviceClient = new ServiceClient();
        OperationClient opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
        //creating message context
        MessageContext outMsgCtx = new MessageContext();
        //assigning message context’s option object into instance variable
        Options opts = outMsgCtx.getOptions();
        //setting properties into option
        opts.setTo(new EndpointReference(
                "http://localhost:8080/axis2/services/DynamicService.DynamicServiceHttpSoap11Endpoint/"));
        opts.setAction("urn:echoEmployee");
        outMsgCtx.setEnvelope(creatSOAPEnvelop());
        opClient.addMessageContext(outMsgCtx);
        opClient.execute(true);

        MessageContext inMsgtCtx = opClient.getMessageContext("In");

        SOAPEnvelope response = inMsgtCtx.getEnvelope();
        System.out.println(response);
    } catch (AxisFault axisFault) {
        axisFault.printStackTrace();
    }
}
 
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:25,代码来源:OperationalClient.java


示例9: testEchoXMLSyncMC

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public void testEchoXMLSyncMC() throws Exception {        
    AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
    Options options = new Options();
    options.setTo(targetEPR);
    options.setAction(operationName.getLocalPart());
    options.setTransportInProtocol(Constants.TRANSPORT_TCP);

    OMFactory fac = OMAbstractFactory.getOMFactory();

    OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
    OMElement method = fac.createOMElement("echoOMElement", omNs);
    OMElement value = fac.createOMElement("myValue", omNs);
    value.setText("Isaac Asimov, The Foundation Trilogy");
    method.addChild(value);
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);

    MessageContext requestContext = new MessageContext();
    requestContext.setConfigurationContext(configContext);
    requestContext.setAxisService(clientService);
    requestContext.setAxisOperation(opdesc);
    requestContext.setEnvelope(envelope);

    ServiceClient sender = new ServiceClient(configContext, clientService);
    sender.setOptions(options);
    OperationClient opClient = sender.createClient(new QName("echoOMElement"));
    opClient.addMessageContext(requestContext);
    opClient.setOptions(options);
    opClient.execute(true);

    MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    SOAPEnvelope env = response.getEnvelope();
    assertNotNull(env);
    env.getBody().serialize(StAXUtils.createXMLStreamWriter(
            System.out));
    sender.cleanup();
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:39,代码来源:TCPEchoRawXMLTest.java


示例10: testEchoXMLSync

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public void testEchoXMLSync() throws Exception {

        Options options = new Options();
        options.setTo(targetEPR);
        options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        options.setTimeOutInMilliSeconds(100000);
        options.setAction(Constants.AXIS2_NAMESPACE_URI + "/" + operationName.getLocalPart());
        options.setTo(targetEPR);

        ConfigurationContext configContext =
                ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                        TestingUtils.prefixBaseDirectory("target/test-resources/integrationRepo"), null);

        ServiceClient sender = new ServiceClient(configContext, null);
        sender.setOptions(options);
        OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

        MessageContext mc = new MessageContext();
        mc.setEnvelope(createEnvelope());
        FileDataSource fileDataSource = new FileDataSource(TestingUtils.prefixBaseDirectory("test-resources/mtom/test.jpg"));
        DataHandler dataHandler = new DataHandler(fileDataSource);
        mc.addAttachment("FirstAttachment", dataHandler);

        mepClient.addMessageContext(mc);
        mepClient.execute(true);
        MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        DataHandler dataHandler2 = response.getAttachment("FirstAttachment");
        assertNotNull(dataHandler);
        compareDataHandlers(dataHandler, dataHandler2);
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:EchoRawSwATest.java


示例11: testMulitref1

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public void testMulitref1() throws AxisFault {
    RPCServiceClient sender = getRPCClient("EchoXMLService", "echoString");
    OMFactory fac = OMAbstractFactory.getOMFactory();

    OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
    OMElement method = fac.createOMElement("echoString", omNs);
    OMElement value = fac.createOMElement("arg0", null);
    value.addAttribute(fac.createOMAttribute("href", null, "#1"));
    method.addChild(value);
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);

    OMElement ref = fac.createOMElement("reference", null);
    ref.addAttribute(fac.createOMAttribute("id", null, "1"));
    ref.setText("hello Axis2");
    envelope.getBody().addChild(ref);

    MessageContext reqMessageContext = new MessageContext();
    OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
  
    reqMessageContext.setEnvelope(envelope);

    opClinet.addMessageContext(reqMessageContext);
    opClinet.execute(true);

    MessageContext responseMessageContx =
            opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

    SOAPEnvelope env = responseMessageContx.getEnvelope();


    assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "hello Axis2");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:35,代码来源:MultirefTest.java


示例12: testaddSameRef

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public void testaddSameRef() throws AxisFault {
    RPCServiceClient sender = getRPCClient("EchoXMLService", "add");
    OMFactory fac = OMAbstractFactory.getOMFactory();

    OMNamespace omNs = fac.createOMNamespace(NAMESPACE, "my");
    OMElement method = fac.createOMElement("add", omNs);
    OMElement value = fac.createOMElement("arg0", null);
    value.addAttribute(fac.createOMAttribute("href", null, "#1"));
    method.addChild(value);

    OMElement value2 = fac.createOMElement("arg1", null);
    value2.addAttribute(fac.createOMAttribute("href", null, "#1"));
    method.addChild(value2);

    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);

    OMElement ref = fac.createOMElement("reference", null);
    ref.addAttribute(fac.createOMAttribute("id", null, "1"));
    ref.setText("10");
    envelope.getBody().addChild(ref);

    MessageContext reqMessageContext = new MessageContext();
    OperationClient opClinet = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
    
    reqMessageContext.setEnvelope(envelope);

    opClinet.addMessageContext(reqMessageContext);
    opClinet.execute(true);

    MessageContext responseMessageContx =
            opClinet.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    SOAPEnvelope env = responseMessageContx.getEnvelope();

    assertEquals(env.getBody().getFirstElement().getFirstElement().getText(), "20");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:MultirefTest.java


示例13: doInvokeOneWay

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public void doInvokeOneWay(MessageContext request) throws WebServiceException {
    // Make sure that a one-way invocation does not attempt to use a separate channel
    // for the response.
    Boolean useAsyncMep = (Boolean) request.getProperty(Constants.USE_ASYNC_MEP);
    if (useAsyncMep != null && useAsyncMep.booleanValue()) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("onewayAsync"));
    }
    
    // We need the qname of the operation being invoked to know which 
    // AxisOperation the OperationClient should be based on.
    // Note that the OperationDesc is only set through use of the Proxy. Dispatch
    // clients do not use operations, so the operationDesc will be null.  In this
    // case an anonymous AxisService with anoymouns AxisOperations for the supported
    // MEPs will be created; and it is that anonymous operation name which needs to
    // be specified
    QName operationName = getOperationNameToUse(request, ServiceClient.ANON_OUT_ONLY_OP);

    InvocationContext ic = request.getInvocationContext();
    ServiceClient svcClient = ic.getServiceClient();
    OperationClient opClient = createOperationClient(svcClient, operationName);

    initOperationClient(opClient, request);

    org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();

    try {
        execute(opClient, true, axisRequestMsgCtx);
    } catch (AxisFault af) {
        // JAXWS 6.4.2 says to throw it...
        // Whatever exception we get here will not be from the server since a one-way
        // invocation has no response.  This will always be a SENDER fault
        if (log.isDebugEnabled()) {
            log.debug(axisRequestMsgCtx.getLogIDString() + " AxisFault received from client: " +
                    af.getMessage());
        }
        throw ExceptionFactory.makeWebServiceException(ClassUtils.getRootCause(af));
    }

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


示例14: execute

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
/**
 * Executes the OperationClient
 *
 * @param opClient   - Fully configured OperationClient
 * @param block      - Indicates if blocking or non-blocking execute
 * @param msgContext - Axis2 MessageContext
 * @throws AxisFault - All exceptions are returned as AxisFaults
 */
private void execute(OperationClient opClient,
                     boolean block,
                     org.apache.axis2.context.MessageContext msgContext) throws AxisFault {
    try {
        // Pre-Execute logging and setup
        preExecute(opClient, block, msgContext);
        //check if Exception should be thrown on SOAPFault
        if(log.isDebugEnabled()){
        	log.debug("Read throwExceptionIfSOAPFault property");
        }
        boolean exceptionToBeThrownOnSOAPFault= ClientUtils.getExceptionToBeThrownOnSOAPFault(msgContext);
        if(log.isDebugEnabled()){
        	log.debug("throwExceptionIfSOAPFault property set on OperationClient.options "+ exceptionToBeThrownOnSOAPFault);
        }
        opClient.getOptions().setExceptionToBeThrownOnSOAPFault(exceptionToBeThrownOnSOAPFault);
        // Invoke the OperationClient
        opClient.execute(block);
    } catch (Throwable e) {
        // Catch all Throwable (including runtime exceptions and Errors) and
        // throw as AxisFault.
        // Since e could be a Throwable (or Error) instead of an Exception, we'll have to wrap it:
        throw AxisFault.makeFault(ExceptionFactory.makeWebServiceException(e));
    } finally {
        // Post-Execute logging and setup
        postExecute(opClient, block, msgContext);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:36,代码来源:AxisInvocationController.java


示例15: postExecute

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
/**
 * Called by execute(OperationClient) to perform post-execute tasks.  Should be a mirror of
 * preExecute
 *
 * @param opClient
 * @param block      - Indicates if blocking or non-blocking execute
 * @param msgContext - Axis2 MessageContext
 */
private void postExecute(OperationClient opClient,
                         boolean block,
                         org.apache.axis2.context.MessageContext msgContext) {
    if (log.isDebugEnabled()) {
        log.debug("End OperationClient.execute(" + block + ")");
    }

    /* TODO Currently this check causes SOAPMessageProviderTests to fail.
    if (log.isDebugEnabled()) {
        // Check for exploded OMSourcedElement
        OMElement bodyElement = null;
        if (msgContext.getEnvelope() != null &&
            msgContext.getEnvelope().getBody() != null) {
            bodyElement = msgContext.getEnvelope().getBody().getFirstElement();     
        }
        
        boolean expanded = false;
        if (bodyElement != null && bodyElement instanceof OMSourcedElementImpl) {
            expanded = ((OMSourcedElementImpl)bodyElement).isExpanded();
        }
        // An exploded xml block may indicate a performance problem.  
        // In general an xml block should remain unexploded unless there is an
        // outbound handler that touches the block.
        if (expanded) {
            log.debug("Developer Debug: Found an expanded xml block:" + bodyElement.getNamespace());
        }
    }
    */
    // Cleanup context
    ThreadContextMigratorUtil
            .performContextCleanup(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, msgContext);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:41,代码来源:AxisInvocationController.java


示例16: makeRequest

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
private List<ResponseData> makeRequest(String session, int iterations, long sleepTime, SOAPEnvelope[] envelopes,
                                       ServiceClient client) throws AxisFault {
    List<ResponseData> responseList = new ArrayList<ResponseData>();

    int i = 0;
    int sessionNumber;
    String[] cookies = new String[3];
    boolean httpSession = session != null && "http".equals(session);
    int cookieNumber;

    while (i < iterations) {

        i++;
        if (sleepTime != -1) {
            try {
                Thread.sleep(sleepTime);
            } catch (InterruptedException ignored) {
            }
        }

        MessageContext messageContext = new MessageContext();
        sessionNumber = getSessionTurn(envelopes.length);

        messageContext.setEnvelope(envelopes[sessionNumber]);
        cookieNumber = getSessionTurn(cookies.length);
        String cookie = cookies[cookieNumber];
        if (httpSession) {
            setSessionID(messageContext, cookie);
        }
        try {
            OperationClient op = client.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)) {
                    cookies[cookieNumber] = receivedCookie;
                }
            }

            SOAPEnvelope responseEnvelope = responseContext.getEnvelope();

            OMElement vElement =
                responseEnvelope.getBody().getFirstChildWithName(new QName("Value"));
            if (log.isDebugEnabled()) {
                log.debug(
                    "Request: " + i + " with Session ID: " + (httpSession ? cookie : sessionNumber) + " ---- " +
                    "Response : with  " + (httpSession && receivedCookie != null ?
                                           (receivedSetCookie != null ? receivedSetCookie : receivedCookie) :
                                           " ") + " " + vElement.getText());
            }

            responseList
                .add(new ResponseData(true, "" + (httpSession ? cookie : sessionNumber), vElement.getText()));

        } catch (AxisFault axisFault) {
            if (log.isDebugEnabled()) {
                log.debug("Request with session id " + (httpSession ? cookie : sessionNumber), axisFault);
            }

            responseList.add(
                new ResponseData(false, "" + (httpSession ? cookie : sessionNumber), axisFault.getMessage()));
        }
    }

    return responseList;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:73,代码来源:LoadBalanceSessionFullClient.java


示例17: sendUsingSwA

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException {

        Options options = new Options();
        options.setTo(new EndpointReference(targetEPR));
        options.setAction("urn:uploadFileUsingSwA");
        options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);

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

        MessageContext mc = new MessageContext();

        System.out.println("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")).
                getFirstChildWithName(new QName("http://services.samples", "imageId")).
                getText();

        Attachments attachment = response.getAttachmentMap();
        dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
        fos.flush();
        fos.close();

        System.out.println("Saved response to file : " + tempFile.getAbsolutePath());

        return response;
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:55,代码来源:MTOMSwAClient.java


示例18: invokeRegistrationService

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public static MessageContext invokeRegistrationService(MessageContext mctx, String registrationService) throws AxisFault {

        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        ConfigurationContext configurationContext = HTCoordinationModuleContentHolder.getInstance().getHtServer().getTaskStoreManager().
                getHumanTaskStore(tenantId).getConfigContext();
        OperationClient opClient = getOperationClient(mctx, configurationContext);
        mctx.getOptions().setParent(opClient.getOptions());

        opClient.addMessageContext(mctx);
        Options operationOptions = opClient.getOptions();

        operationOptions.setTo(new EndpointReference(registrationService));
        operationOptions.setAction(Constants.WS_COOR_REGISTERATION_ACTION);
//        operationOptions.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTPS);

        //Setting basic auth headers. Reading those information using HT server config.
        HumanTaskServerConfiguration serverConfig = HTCoordinationModuleContentHolder.getInstance().getHtServer().getServerConfig();
//        String tenantDomain = MultitenantUtils.getTenantDomainFromUrl(registrationService);
//        if (registrationService.equals(tenantDomain)) {
//            //this is a Super tenant registration service
//            if (log.isDebugEnabled()) {
//                log.debug("Sending Username" + serverConfig.getRegistrationServiceAuthUsername() + " - " + serverConfig.getRegistrationServiceAuthPassword());  //TODO REMOVE this
//            }
//            setBasicAccessSecurityHeaders(serverConfig.getRegistrationServiceAuthUsername(), serverConfig.getRegistrationServiceAuthPassword(), true, operationOptions);
//        } else {
//            if (log.isDebugEnabled()) {
//                log.debug("Sending ws-coor Registration request to tenant domain: " + tenantDomain);
//            }
//            // Tenant's registration service
//
//            String username = serverConfig.getRegistrationServiceAuthUsername() + "@" + tenantDomain;
//            String pass = serverConfig.getRegistrationServiceAuthPassword();
//            if (log.isDebugEnabled()) {
//                log.debug("Sending Username" + username + " - " + pass);  //TODO REMOVE this
//            }
//            setBasicAccessSecurityHeaders(username,pass,true,operationOptions);
//        }

        HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();
        basicAuthentication.setPreemptiveAuthentication(true);
        basicAuthentication.setUsername(serverConfig.getRegistrationServiceAuthUsername());
        basicAuthentication.setPassword(serverConfig.getRegistrationServiceAuthPassword());

        operationOptions.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);

        if (log.isDebugEnabled()) {
            log.debug("Invoking Registration service");
        }
        opClient.execute(true);

        MessageContext responseMessageContext =
                opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        return responseMessageContext;

    }
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:56,代码来源:ServiceUtils.java


示例19: invokeService

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
public static void invokeService(ServiceInvocationContext partnerInvocationContext,
                                 ConfigurationContext configContext)
        throws AxisFault {
    //TODO check for one-way
    MessageContext mctx = partnerInvocationContext.getInMessageContext();
    OperationClient opClient = getOperationClient(partnerInvocationContext, configContext);
    mctx.getOptions().setParent(opClient.getOptions());

    /*
    Else we assume that the epr is not changed by the process.
    In this case there's a limitation we cannot invoke the epr in the wsdl
    (by assigning that epr by partnerlink assign) if there is a endpoint
    configuration available for that particular service
    */
    opClient.addMessageContext(mctx);
    Options operationOptions = opClient.getOptions();

    if (partnerInvocationContext.getUep().isAddressingEnabled()) {
        //Currently we set the action manually, but this should be handled by
        // addressing module it-self?
        String action = getAction(partnerInvocationContext);
        if (log.isDebugEnabled()) {
            log.debug("Soap action: " + action);
        }
        operationOptions.setAction(action);
        //TODO set replyto as well
        //operationOptions.setReplyTo(mctx.getReplyTo());
    }
    operationOptions.setTo(partnerInvocationContext.getUep());

    opClient.execute(true);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:33,代码来源:AxisServiceUtils.java


示例20: addPropertyToOperationClient

import org.apache.axis2.client.OperationClient; //导入依赖的package包/类
private void addPropertyToOperationClient(OperationClient operationClient,
                                          String propertyKey,
                                          Object propertyValue) {
    operationClient.getOptions().setProperty(propertyKey, propertyValue);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:6,代码来源:HTTPBindingHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Kind类代码示例发布时间:2022-05-23
下一篇:
Java Before类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap