Reputation: 91
Good day!
I recently started studying WSO ESB
My service receives requests and responds in XML format, example:
<!--The query in my service --> POST / HTTP/1.1 Content-Type: text/xml; charset=utf-8 Content-Length: 109 <req> <Value>How are you?</Value> </req> <!--The response from the service --> HTTP/1.1 200 OK Content-Length: 120 Content-Type: text/xml; charset=utf-8 <res> <Value>Very good!!!</Value> </res>
I need to transform a SOAP request from a client via a proxy service to and from XML in the SOAP client
Example SOAP request and response in proxyservice
<!--The request from the client to proxy service--> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <Question xmlns="http://MyTestService"> <Value>How are you?</Value> </Question> </soap:Body> </soap:Envelope> <!--Answer the service proxy to the client--> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <QuestionResponse xmlns="http://CyberPlatService"> <Fun1Result>Very good!!!</Fun1Result> </QuestionResponse> </s:Body> </s:Envelope>
Here is my proxy service
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CyberPlatProxy" transports="https http" startOnLoad="true" trace="disable"> <target> <inSequence> <payloadFactory media-type="xml"> <format> <req> <Value>$1</Value> </req> </format> <args> <arg xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" expression="//Question/Value"/> </args> </payloadFactory> <property name="messageType" value="text/xml" scope="axis2" type="STRING"/> <property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/> <log level="custom"/> <send> <endpoint> <http method="post" uri-template="http://localhost:2009/"/> </endpoint> </send> </inSequence> <outSequence> <payloadFactory media-type="xml" description="res"> <format> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetStaysResponse xmlns="http://CyberPlatService"> <GetStaysResult>$1</GetStaysResult> </GetStaysResponse> </s:Body> </s:Envelope> </format> <args> <arg expression="//Value"/> </args> </payloadFactory> <property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/> <send/> </outSequence> <faultSequence/> </target> </proxy>
Nothing happens, what am I doing wrong?
Upvotes: 3
Views: 2049
Reputation: 5946
The "Question" node belongs to http://MyTestService
namespace so, your xpath //Question/Value
can't work, you should change :
<arg xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" expression="//Question/Value"/>
to :
<arg xmlns:test="http://MyTestService" expression="//test:Question/test:Value/text()"/>
Upvotes: 3