I'm building a middleware based on Mule ESB, implementing Asyncronous Web Services. I have a client who sends Soap requests to my ESB endpoint implemented with CXF Jax-ws service with WS-Addressing feature enabled, via SoapUI. I send the response string "Hello" and start processing the input parameters to make the asyncronous reply to the client, who has a callBack web service endpoint.
The request has the correct Soap Header, with the tag ReplyTo, which has the address of the callBack endpoint in the client.
Here is my server jax-ws web service code:
@WebService(serviceName = "OrderReceive")
@Addressing
public class OrderReceive {
public String perform(String id, long creditCardNumber, List<Product> products) {
//Save values to process the async reply
setSessionVariable(id,creditCardNumber,products);
return "Hello, i will send the response soon";
}
}
The thing is my web service is autorespoding to the ReplyTo address and i don't have any control of the response.
Is it possible to intercept that response, and set the correct body of it?
Why is my web service autoresponding?
Regards
this is why I love stackoverflow. I have never heard about this!!!
Your "automatic response" can be caused by a behavior in mule:
If mule detects the reply_to property in the message , launches an automatic response to that endpoint. This is for request-reply funcionality in jms, but maybe is affecting the http connector.
Source of this :
Automatic response when sending message
-------------------*------------------------
After my researching I found that the proper behaviour of ws-addressing is:
client -- SOAP request ( on port A ) --> server
client <-- HTTP 202 ( "Hello, i will send the response soon" HTTP body ) --- server
client <-- SOAP response ("Response is ready!!" on port B ) --- server
Source :jax-ws 2.2.8 and ws-addressing
To make this possible , we need:
1.- Server Endpoint : mule/cxf
2.- Client of service : soapui
3.- Callback Endpoint : to recieve the async response (I think this is in mule)
Understood this, the offical documentation about it is sad :
MULE 3.7 Enabling WS-Addressing
I think you need the CallBack Enpoint to create and execute the async response. I have not found anything in mule :(.
Here some links of java implementation, no mule:
Asynchronous web services with WS-Addressing
Invoke a single port async service using JAX-WS and WS-Addressing
-------------------*------------------------
An alternative solution could be :
1.- Web Service in mule/cxf without addressing.
2.- Inside operation method :
public Response operation ( Request requestPayload ) {
MuleClient client = new MuleClient(muleContext);
client.dispatch("jms://my.queue", requestPayload , null);// this is async
return new Response("Hello, i will send the response soon.");
}
Reference : Using the Mule Client
3.- Create a jms inbound endpoint listen to : jms://my.queue
<flow>
<jms:inbound-endpoint queue="my.queue" >
<do something>
<launch a response to client>
</flow>
This could be :
a.- By email to client
b.- Consume a service published by client
c.- SMS notification
d.- Whatever
This approach can be more flexible and support future crazy requirements.
If you need some help with mule cxf service or jms, let me know to help you!!