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


Java OperationClient类代码示例

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


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


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