I tried the following codes in mediation in WSO2 server
Following code for insequence
mediation
<sequence name="SOAPtoJSON" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom" separator=",">
<property name="TRACE" value="Global Mediation Extension"/>
</log>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
The above insequence works fine and converts the input from SOAP to JSON and forward it to the endpoint.
The SOAP request given to the WSO2 Server via WSO2 Server API Console was,
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ecomreceipt">
<soapenv:Header/>
<soapenv:Body>
<validatepassbook xmlns="https://10.122.0.32:8243/gpp20038/1.0.0/">
<Mode>$1</Mode>
<Action>$2</Action>
<Attribute>$3</Attribute>
</validatepassbook>
</soapenv:Body>
And then, I logged the request from the WSO2 Server in the endpoint, log shows the following
{"validatepassbook":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","Mode":{"@type":"xsd:string","$":"zmzIf0CMfm5ta8lg5xc6Bj1tOEEljipbbrbX2Ph8XFxGyGl5T4vhzzmLIpNuSh6W"},"Action":{"@type":"xsd:string","$":"KGI1718SGS439-KGI14306-SGS3"},"Attribute":{"@type":"xsd:string","$":7904045393}}}
Following code for outsequence
mediation
<sequence name="JSONtoSOAP" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<payloadFactory media-type="xml">
<format>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.cdyne.com/PhoneVerify/query">
<SOAP-ENV:Body>
<ns1:CheckPhoneNumbers>
<ns1:PhoneNumbers>
<ns1:string>$1</ns1:string>
</ns1:PhoneNumbers>
<ns1:LicenseKey>$2</ns1:LicenseKey>
</ns1:CheckPhoneNumbers>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</format>
<args>
<arg evaluator="xml" expression="//request/PhoneNumber"/>
<arg evaluator="xml" expression="//request/LicenseKey"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>
And then, I logged the respond that to be sent to WSO2 Server in the endpoint, log shows the following
"{\"request\":{\"PhoneNumber\":\"18006785432\",\"LicenseKey\":\"0\"}}"
And then, I got the output in WSO2 Server API Console was,
Response Body
<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.cdyne.com/PhoneVerify/query"><SOAP-ENV:Body><ns1:CheckPhoneNumbers><ns1:PhoneNumbers><ns1:string/></ns1:PhoneNumbers><ns1:LicenseKey/></ns1:CheckPhoneNumbers></SOAP-ENV:Body></SOAP-ENV:Envelope>
The above response with empty values , but I expect like following reponse
<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.cdyne.com/PhoneVerify/query"><SOAP-ENV:Body><ns1:CheckPhoneNumbers><ns1:PhoneNumbers><ns1:string/>18006785432</ns1:PhoneNumbers><ns1:LicenseKey>0</ns1:LicenseKey></ns1:CheckPhoneNumbers></SOAP-ENV:Body></SOAP-ENV:Envelope>