[esb-java-user] Returning response from a mediator
Soundarapandian, Sivakumar
ssoundarapandian at road-inc.com
Fri Jul 6 03:26:32 PDT 2007
Thanks, that works.
________________________________
From: esb-java-user-bounces at wso2.org
[mailto:esb-java-user-bounces at wso2.org] On Behalf Of Asankha C. Perera
Sent: Friday, July 06, 2007 3:50 PM
To: esb-java-user at wso2.org
Subject: Re: [esb-java-user] Returning response from a mediator
Siva
Oh ok, I am sorry.. seems like your client is not using WS-Addressing.
So you really don't have a ReplyTo in your incoming message which
explains the problem. Just remove the "To" header then and that will do
for this scenario.
The reasoning behind this is that over HTTP an incoming message to a
Proxy say Echo would have a value of "/soap/Echo" which you usually
would want to use for routing decisions. However, when sending a
response, the "To" field should have a valid EPR (e.g. like the ReplyTo
EPR sent by the client over which it is expecting the response) or
should be null, so that the ESB will know that the message is a response
and would know to send it back over the same transport. However for
example if you are using JMS in this situation - you may want to set the
"To" header in a similar situation to some other queue maybe..
I have attached the definition for a sample Echo service this way.
<syn:proxy name="Echo" startOnLoad="true">
<syn:target>
<syn:inSequence>
<syn:property name="RESPONSE" value="true"/>
<syn:header name="To" action="remove"/>
<syn:send/>
</syn:inSequence>
<syn:outSequence>
<syn:send/>
</syn:outSequence>
</syn:target>
</syn:proxy>
Now when I try this (i.e. without ws-addressing), I get the same request
echoed back as can be seen below:
asankha at asankha:/opt/wso2esb-1.0/samples/axis2Client$ ant stockquote
-Dtrpurl=http://localhost:8080/soap/Echo
...
[java] java.lang.Exception: Unexpected response :
<m0:getQuotexmlns:m0="http://services.samples/xsd"
<http://services.samples/xsd>
><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote>
...
Hope this helps
regards
asankha
Soundarapandian, Sivakumar wrote:
I tried this with
<proxy name="TMWAdapterProxy">
<target>
<inSequence>
<class
name="com.atroad.mediator.TMWMockMediator"/>
<property
name="RESPONSE" value="true"/>
<header name="To"
expression="get-property('ReplyTo')"/>
<send/>
</inSequence>
<outSequence>
</outSequence>
</target>
</proxy>
Currently my mediator is not doing anything other than doing a println.
So I would expect the same request to comeback as response. But I am
getting the following error. Am I missing something?
DEBUG [06 Jul 15:11:09] PropertyMediator - Property mediator ::
mediate()
DEBUG [06 Jul 15:11:09] PropertyMediator - Setting : RESPONSE property
(scope:d
efault) = true
DEBUG [06 Jul 15:11:09] HeaderMediator - Header mediator <Set> ::
mediate()
INFO [06 Jul 15:11:09] ESBRegistry - ==> Repository fetch of resource
with key
: ReplyTo
DEBUG [06 Jul 15:11:09] HeaderMediator - Setting header : To to : null
DEBUG [06 Jul 15:11:09] SendMediator - Send mediator :: mediate()
DEBUG [06 Jul 15:11:09] SendMediator - Sending message using implicit
message p
roperties..
DEBUG [06 Jul 15:11:09] SendMediator - Sending To: null
DEBUG [06 Jul 15:11:09] SendMediator - SOAPAction: urn:anonOutInOp
DEBUG [06 Jul 15:11:09] SendMediator - Body :
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://sc
hemas.xmlsoap.org/soap/envelope/"><soapenv:Body><m0:getForm
xmlns:m0="http://ser
vices.samples/xsd"><m0:formId>100</m0:formId></m0:getForm></soapenv:Body
></soape
nv:Envelope>
ERROR [06 Jul 15:11:09] HttpCoreNIOSender - Malformed destination EPR :
null
java.net.MalformedURLException
at java.net.URL.<init>(URL.java:601)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at
org.apache.axis2.transport.nhttp.HttpCoreNIOSender.sendAsyncRequest(H
ttpCoreNIOSender.java:261)
at
org.apache.axis2.transport.nhttp.HttpCoreNIOSender.invoke(HttpCoreNIO
Sender.java:210)
at
org.apache.axis2.engine.AxisEngine$TransportNonBlockingInvocationWork
er.run(AxisEngine.java:571)
at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Wor
ker.runTask(ThreadPoolExecutor.java:665)
at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Wor
ker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:595)
INFO [06 Jul 15:11:09] AxisEngine - [MessageContext:
logID=urn:uuid:DDFC49319B
A42BC34A1183714870265] Malformed destination EPR : null
________________________________
From: esb-java-user-bounces at wso2.org
[mailto:esb-java-user-bounces at wso2.org] On Behalf Of Asankha C. Perera
Sent: Friday, July 06, 2007 2:16 PM
To: esb-java-user at wso2.org
Subject: Re: [esb-java-user] Returning response from a mediator
Hi Siva
The sample #7
<https://wso2.org/project/esb/java/1.0/docs/ESB_Samples.html#Sample7>
shows how to create a custom fault message (when a validation fails) and
change the direction of this message to a "response" and then send it
back to the client.
So if your MockMediator handles the incoming message and creates the
response to be sent back, you could to the following after your
mediator. Note that a mediator has state (i.e. an instance for each
occurrence in a configuration) and may be shared by multiple threads.
<property name="RESPONSE" value="true"/>
<header name="To" expression="get-property('ReplyTo')"/>
<send/>
thanks
asankha
Asankha C. Perera wrote:
Forwarding this mail from Siva that somehow bounced.. - asankha
Hi,
I have a proxy that does not have an end point. I have a class mediator
and the request is received by the mediator. I want to return a response
from the mediator. How can I do that? Here is the configuration I have
<definitions xmlns="http://ws.apache.org/ns/synapse"
<http://ws.apache.org/ns/synapse> >
<proxy name="TestAdapterProxy">
<target>
<inSequence>
<class
name="com.atroad.mediator.MockMediator"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
</definitions>
Thanks,
Siva
________________________________
_______________________________________________
Esb-java-user mailing list
Esb-java-user at wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-user
________________________________
_______________________________________________
Esb-java-user mailing list
Esb-java-user at wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wso2.org/pipermail/esb-java-user/attachments/20070706/83616890/attachment-0001.htm
More information about the Esb-java-user
mailing list