Reputation: 195
Right now some services are exposed using REST while some using SOAP. There are more than 2000 services. The requirement is to expose all these in SOAP 1.2 and REST API (yes both).
I was wondering if I can take build something on an integration layer (preferable Mulesoft) to do this. The integration layer will call the services and then expose/convert "REST as SOAP" and "SOAP as REST"
How may I achieve the above flow in MuleSoft? An algorithm would be very very helpful.
Thanks in advance.
For example: changeName(string id, string newName) Should be called from SOAP as:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<urn:changeName>
<urn:id>1001</urn:id>
<urn:newName>Steve Jobs</urn:newName>
</urn:changeName>
</soapenv:Body>
</soapenv:Envelope>
AND also form REST, for example
http://www.mywebserviceurl/changeName/
POST
{id:1001, name:Steve Jobs}
Upvotes: 2
Views: 2194
Reputation: 11
This is the way you can create for REST to SOAP 1. Create a mule flow with http listner to accept SOAP request 2. Use Datamapper to convert xml to json format 3. use http out bound endpoint to call a REST service and pass the json payload 4. use datamapper to convert response json to xml
And here is SOAP to REST 1. Create a mule flow with http listner to accept REST request 2. Use Datamapper to convert json to xml format 3. use web services consumer to call a SOQP service and pass the xml payload 4. use datamapper to convert response xml to json
Upvotes: 0
Reputation: 8311
SOAP is a protocol and REST is an architectural style. And they are different in nature.
In your usecase, what you can do is
you can create a Mule flow, which will accept SOAP request
and then you can extract the value using XPATH3 , store it in a flow variable ,
then create a JSON request for your actual REST web service using Expression transformer reference :- How to transform json-to-json document in Mule ESB,
and post it to your REST service using Mule HTTP outbound or request component to the actual REST service already exposed
Get the JSON response from the actual REST service, and parse it and extract the values using json:json-to-object-transformer
, and store the value in flow variables
Use Data mapper or if you are use Mule CE, use XSLT to create SOAP response back to the client ref: https://developer.mulesoft.com/docs/display/current/XSLT+Transformer
The above is the simple and easiest way to create a client api/flow in Mule that will accept SOAP request from client and transform into JSON request for your REST service exposed and will post it through HTTP to the actual service.
This way you can make your Mule as an interface application between your SOAP call and actual REST service
,
Upvotes: 1