Reputation: 160
I am using wso2esb4.7.0.i am working with different operations in single proxy i have found one example blog and i go through that.But i am not so clear about that blog my proxy is like this
<inSequence xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="M1" value="***************HITTING Transaction PROXY****************"/>
</log>
<property name="id" expression="//id/text()"/>
<property name="name" expression="//name/text()"/>
<payloadFactory media-type="xml">
<format>
<p:my_insert xmlns:p="http://ws.wso2.org/dataservice">
<xs:id xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:id>
<xs:name xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:name>
</p:my_insert>
</format>
<args>
<arg expression="get-property('id')" evaluator="xml"/>
<arg expression="get-property('name')" evaluator="xml"/>
</args>
</payloadFactory>
<callout serviceURL="https://localhost:9445/services/DTPDS/" action="urn:my_insert">
<source xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
<payloadFactory media-type="xml">
<format>
<p:pos_insert xmlns:p="http://ws.wso2.org/dataservice">
<xs:id xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:id>
<xs:name xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:name>
</p:pos_insert>
</format>
<args>
<arg expression="get-property('id')" evaluator="xml"/>
<arg expression="get-property('name')" evaluator="xml"/>
</args>
</payloadFactory>
<callout serviceURL="https://localhost:9445/services/DTPDS/" action="urn:pos_insert">
<source xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
<log level="full>
<property name="message" value="working"/>
</log>
<inSequence>
In callout meditor above Service url for hitting the endpoint and action is about endpoint operation But What is the use of SOURCE and TARGET i tried to receive the endpoint response in to this source as well target also but i am unable to get response then what is the use of both and how i am send my response to my client it means where can i get this response where i need to define my receive sequence Please refer me any clear explanation blog
Upvotes: 0
Views: 1123
Reputation: 2295
'source' specifies the payload for the request message using an XPath expression or a registry key. The 'target' specifies a node at which the resulting payload(response) will be attached in the current message context.
By specifying as given in your sample config, response will be attached as the first child of the SOAP message body in message context.
The difference between callout mediator and send mediator is that callout mediator will return the response to the same sequence by doing a blocking call. In send mediator response is returned to the OutSequence in where you can send it back to the client.
So in here you can use the Send mediator (end of the inSequence) in order to send the message to the OutSequence. Then again do a send inside the outSequence to make it returned to the client.
ex:
add Below configs to end of the inSequence
<header name="To" action="remove"/>
<property name="RESPONSE" value="true"/>
<send/>
Then inside outSequence, again do a send.
<outSequence>
<send/>
</outSequence>
Upvotes: 1