use of org.apache.axis2.description.OutInAxisOperation 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.description.OutInAxisOperation in project wso2-axis2-transports by wso2.
the class UDPSender method waitForReply.
private void waitForReply(MessageContext messageContext, DatagramSocket datagramSocket, String contentType) throws IOException {
// message context in asnych model
if (!(messageContext.getAxisOperation() instanceof OutInAxisOperation) && messageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null) {
return;
}
// TODO set the maximum size parameter
byte[] inputBuffer = new byte[4096];
DatagramPacket packet = new DatagramPacket(inputBuffer, inputBuffer.length);
datagramSocket.receive(packet);
// create the soap envelope
try {
MessageContext respMessageContext = messageContext.getOperationContext().getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
InputStream inputStream = new ByteArrayInputStream(inputBuffer, 0, packet.getLength());
SOAPEnvelope envelope = TransportUtils.createSOAPMessage(respMessageContext, inputStream, contentType);
respMessageContext.setEnvelope(envelope);
} catch (XMLStreamException e) {
throw new AxisFault("Can not build the soap message ", e);
}
}
use of org.apache.axis2.description.OutInAxisOperation in project wso2-axis2-transports by wso2.
the class MailTransportSender method waitForReply.
private void waitForReply(MessageContext msgContext, String mailMessageID) throws AxisFault {
// message context in asnych model
if (!(msgContext.getAxisOperation() instanceof OutInAxisOperation) && (msgContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null)) {
return;
}
ConfigurationContext configContext = msgContext.getConfigurationContext();
// if the mail message listner has not started we need to start it
if (!configContext.getListenerManager().isListenerRunning(MailConstants.TRANSPORT_NAME)) {
TransportInDescription mailTo = configContext.getAxisConfiguration().getTransportIn(MailConstants.TRANSPORT_NAME);
if (mailTo == null) {
handleException("Could not find the transport receiver for " + MailConstants.TRANSPORT_NAME);
}
configContext.getListenerManager().addListener(mailTo, false);
}
SynchronousCallback synchronousCallback = new SynchronousCallback(msgContext);
Map callBackMap = (Map) msgContext.getConfigurationContext().getProperty(BaseConstants.CALLBACK_TABLE);
callBackMap.put(mailMessageID, synchronousCallback);
synchronized (synchronousCallback) {
try {
synchronousCallback.wait(msgContext.getOptions().getTimeOutInMilliSeconds());
} catch (InterruptedException e) {
handleException("Error occured while waiting ..", e);
}
}
if (!synchronousCallback.isComplete()) {
// when timeout occurs remove this entry.
callBackMap.remove(mailMessageID);
handleException("Timeout while waiting for a response");
}
}
use of org.apache.axis2.description.OutInAxisOperation in project carbon-business-process by wso2.
the class AnonymousServiceFactory method createAnonymousService.
private static AxisService createAnonymousService(AxisConfiguration axisCfg, String serviceKey) {
try {
OutOnlyAxisOperation outOnlyOperation = new OutOnlyAxisOperation(ServiceClient.ANON_OUT_ONLY_OP);
OutInAxisOperation outInOperation = new OutInAxisOperation(ServiceClient.ANON_OUT_IN_OP);
AxisService axisAnonymousService = new AxisService(serviceKey);
axisAnonymousService.addOperation(outOnlyOperation);
axisAnonymousService.addOperation(outInOperation);
// set a right default action *after* operations have been added to the service.
outOnlyOperation.setSoapAction("");
outInOperation.setSoapAction("");
if (log.isDebugEnabled()) {
log.debug("Creating Client Service: " + serviceKey);
}
axisAnonymousService.setClientSide(true);
axisCfg.addService(axisAnonymousService);
return axisAnonymousService;
} catch (AxisFault axisFault) {
handleException("Adding service to axis configuration failed.", axisFault);
}
return null;
}
use of org.apache.axis2.description.OutInAxisOperation in project carbon-business-process by wso2.
the class AnonymousServiceFactory method createAnonymousService.
private static AxisService createAnonymousService(AxisConfiguration axisCfg, String serviceKey) {
try {
OutOnlyAxisOperation outOnlyOperation = new OutOnlyAxisOperation(ServiceClient.ANON_OUT_ONLY_OP);
OutInAxisOperation outInOperation = new OutInAxisOperation(ServiceClient.ANON_OUT_IN_OP);
AxisService axisAnonymousService = new AxisService(serviceKey);
axisAnonymousService.addOperation(outOnlyOperation);
axisAnonymousService.addOperation(outInOperation);
// set a right default action *after* operations have been added to the service.
outOnlyOperation.setSoapAction("");
outInOperation.setSoapAction("");
if (log.isDebugEnabled()) {
log.debug("Creating Client Service: " + serviceKey);
}
axisAnonymousService.setClientSide(true);
axisCfg.addService(axisAnonymousService);
return axisAnonymousService;
} catch (AxisFault axisFault) {
handleException("Adding service to axis configuration failed.", axisFault);
}
return null;
}
Aggregations