WSO2. How do I convert a SOAP message to XML and send it to a service?
Good day!
I recently started learning WSO ESB
My service receives requests and responds in XML format like:
<!--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 using a proxy service to and from an XML file in the SOAP client
Sample 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?
+3
source to share
1 answer
The "question" node belongs to a namespace http://MyTestService
, so your xpath //Question/Value
cannot work, you must 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()"/>
+3
source to share