Search in sources :

Example 1 with ClientOptions

use of org.apache.axis2.transport.testkit.client.ClientOptions in project carbon-business-process by wso2.

the class AxisServiceUtils method getOperationClient.

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);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 2 with ClientOptions

use of org.apache.axis2.transport.testkit.client.ClientOptions in project carbon-business-process by wso2.

the class ServiceUtils method getOperationClient.

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);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 3 with ClientOptions

use of org.apache.axis2.transport.testkit.client.ClientOptions in project wso2-axis2-transports by wso2.

the class JMSRequestResponseClient method sendMessage.

public IncomingMessage<T> sendMessage(ClientOptions options, ContentType contentType, T message) throws Exception {
    String correlationId = doSendMessage(options, contentType, message);
    MessageConsumer consumer = replySession.createConsumer(replyDestination, "JMSCorrelationID = '" + correlationId + "'");
    try {
        Message replyMessage = consumer.receive(8000);
        return new IncomingMessage<T>(new ContentType(replyMessage.getStringProperty("Content-Type")), jmsMessageFactory.parseMessage(replyMessage));
    } finally {
        consumer.close();
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) Message(javax.jms.Message) ContentType(javax.mail.internet.ContentType) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage)

Example 4 with ClientOptions

use of org.apache.axis2.transport.testkit.client.ClientOptions in project wso2-axis2-transports by wso2.

the class AxisTestClient method send.

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);
}
Also used : OperationClient(org.apache.axis2.client.OperationClient) MessageContext(org.apache.axis2.context.MessageContext) Attachments(org.apache.axiom.attachments.Attachments)

Example 5 with ClientOptions

use of org.apache.axis2.transport.testkit.client.ClientOptions in project wso2-axis2-transports by wso2.

the class AxisRequestResponseTestClient method sendMessage.

public IncomingMessage<AxisMessage> sendMessage(ClientOptions options, ContentType contentType, AxisMessage message) throws Exception {
    MessageContext responseMsgContext = send(options, message, ServiceClient.ANON_OUT_IN_OP, true, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    Assert.assertFalse(responseMsgContext.isServerSide());
    for (MessageContextValidator validator : validators) {
        validator.validate(responseMsgContext, true);
    }
    return new IncomingMessage<AxisMessage>(null, new AxisMessage(responseMsgContext));
}
Also used : IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) MessageContext(org.apache.axis2.context.MessageContext) MessageContextValidator(org.apache.axis2.transport.testkit.axis2.MessageContextValidator) AxisMessage(org.apache.axis2.transport.testkit.message.AxisMessage)

Aggregations

Options (org.apache.axis2.client.Options)7 AxisOperation (org.apache.axis2.description.AxisOperation)7 ServiceContext (org.apache.axis2.context.ServiceContext)6 ServiceGroupContext (org.apache.axis2.context.ServiceGroupContext)6 AxisService (org.apache.axis2.description.AxisService)6 ContentType (javax.mail.internet.ContentType)5 IncomingMessage (org.apache.axis2.transport.testkit.message.IncomingMessage)5 QName (javax.xml.namespace.QName)4 OperationClient (org.apache.axis2.client.OperationClient)4 MessageContext (org.apache.axis2.context.MessageContext)4 SynapseException (org.apache.synapse.SynapseException)4 EndpointReference (org.apache.axis2.addressing.EndpointReference)3 MessageContext (org.apache.synapse.MessageContext)3 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)3 Set (java.util.Set)2 SOAPFactory (org.apache.axiom.soap.SOAPFactory)2 AxisFault (org.apache.axis2.AxisFault)2 AxisMessage (org.apache.axis2.transport.testkit.message.AxisMessage)2 AbstractEndpoint (org.apache.synapse.endpoints.AbstractEndpoint)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1