use of org.apache.axis2.client.ServiceClient in project tdi-studio-se by Talend.
the class MSCRMClient method setServiceClientOptions.
private static void setServiceClientOptions(ServiceClient sc, SecurityData securityData) throws AxisFault, XMLStreamException {
Options options = sc.getOptions();
options.setMessageId("urn:uuid:" + UUID.randomUUID().toString());
EndpointReference endPoint = new EndpointReference("http://www.w3.org/2005/08/addressing/anonymous");
options.setReplyTo(endPoint);
sc.setOptions(options);
sc.addHeader(createCRMSecurityHeaderBlock(securityData));
HttpTransportProperties.ProxyProperties proxyProps = getProxyProperties();
if (proxyProps != null) {
sc.getOptions().setProperty(HTTPConstants.PROXY, proxyProps);
}
try {
sc.engageModule("addressing");
} catch (AxisFault e) {
logger.error(e.getMessage());
throw e;
}
}
use of org.apache.axis2.client.ServiceClient in project wso2-axis2-transports by wso2.
the class TCPEchoRawXMLTest method testEchoXMLASync.
public void testEchoXMLASync() throws Exception {
OMElement payload = createPayload();
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_TCP);
options.setAction(Constants.AXIS2_NAMESPACE_URI + "/" + operationName.getLocalPart());
AxisCallback axisCallback = new AxisCallback() {
public void onMessage(MessageContext msgContext) {
try {
msgContext.getEnvelope().serialize(StAXUtils.createXMLStreamWriter(System.out));
finish = true;
} catch (XMLStreamException e) {
onError(e);
}
}
public void onFault(MessageContext msgContext) {
try {
msgContext.getEnvelope().serialize(StAXUtils.createXMLStreamWriter(System.out));
finish = true;
} catch (XMLStreamException e) {
onError(e);
}
}
public void onError(Exception e) {
log.info(e.getMessage());
finish = true;
}
public void onComplete() {
finish = true;
}
};
ServiceClient sender = new ServiceClient(configContext, clientService);
sender.setOptions(options);
sender.sendReceiveNonBlocking(operationName, payload, axisCallback);
int index = 0;
while (!finish) {
Thread.sleep(1000);
index++;
if (index > 10) {
throw new AxisFault("Server was shutdown as the async response take too long to complete");
}
}
sender.cleanup();
}
use of org.apache.axis2.client.ServiceClient in project wso2-axis2-transports by wso2.
the class TCPEchoRawXMLTest method testEchoXMLSyncMC.
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();
}
use of org.apache.axis2.client.ServiceClient in project wso2-axis2-transports by wso2.
the class AxisTestClient method setUp.
@Setup
@SuppressWarnings("unused")
private void setUp(AxisTestClientContext context, Channel channel, AxisTestClientConfigurator[] configurators) throws Exception {
this.configurators = configurators;
sender = context.getSender();
serviceClient = new ServiceClient(context.getConfigurationContext(), null);
axisOptions = new Options();
axisOptions.setTo(channel.getEndpointReference());
serviceClient.setOptions(axisOptions);
}
use of org.apache.axis2.client.ServiceClient in project wso2-axis2-transports by wso2.
the class UDPTest method testSoapOverUdpWithEchoService.
public void testSoapOverUdpWithEchoService() throws Exception {
Options options = new Options();
options.setTo(new EndpointReference("udp://127.0.0.1:3333?contentType=text/xml+soap"));
options.setAction(Constants.AXIS2_NAMESPACE_URI + "/echoOMElement");
options.setUseSeparateListener(true);
options.setTimeOutInMilliSeconds(Long.MAX_VALUE);
ServiceClient serviceClient = new ServiceClient(getClientCfgCtx(), null);
serviceClient.setOptions(options);
// We need to set up the anonymous service Axis uses to get the response
AxisService clientService = serviceClient.getServiceContext().getAxisService();
clientService.addParameter(UDPConstants.PORT_KEY, 4444);
clientService.addParameter(UDPConstants.CONTENT_TYPE_KEY, "text/xml+soap");
OMElement response = serviceClient.sendReceive(createPayload());
assertEchoResponse(response);
}
Aggregations