Wso2 ESB can convert anything to anything. Today I'm going to explain the below scenario.
Scenario :-
1. Soap client send a request to ESB with soap header.
2. ESB remove soap header and invoke the REST service which only accept XML format.
3. REST service generate a response in xml format
4. ESB adding soap headers to response and send back to SOAP client.
As an example REST service, I'm going to use jaxrs_basic service in WSO2 Application server. Download wso2 application server from this link
Step 1 :-
Change the offset value in carbon.xml file which is located in <AS_HOME>/repository/conf directory.
If you started WSO2 ESB in offset "0" set offset in application server as "1"
<Offset>1</Offset>
Start wso2 application server
Step 2 :-
Start ESB (make sure you do not have same offset value in both ESB and Application Server)
Go to the management console and add a custom proxy service in WSO2 ESB.
Step 3 :-
Create a soap ui project for CustomerServiceProxy with the endpoint url defined in Service dashboard(as shown in below screenshot)
According to my setup, this is the endpoint url
https://madura:8243/services/CustomerServiceProxy
Step 4 :-
Send the below sample soap request using soap ui.
Scenario :-
1. Soap client send a request to ESB with soap header.
2. ESB remove soap header and invoke the REST service which only accept XML format.
3. REST service generate a response in xml format
4. ESB adding soap headers to response and send back to SOAP client.
As an example REST service, I'm going to use jaxrs_basic service in WSO2 Application server. Download wso2 application server from this link
Step 1 :-
Change the offset value in carbon.xml file which is located in <AS_HOME>/repository/conf directory.
If you started WSO2 ESB in offset "0" set offset in application server as "1"
<Offset>1</Offset>
Start wso2 application server
Step 2 :-
Start ESB (make sure you do not have same offset value in both ESB and Application Server)
Go to the management console and add a custom proxy service in WSO2 ESB.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="CustomerServiceProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <filter xpath="//getCustomer"> <property name="REST_URL_POSTFIX" expression="//getCustomer/id" scope="axis2" type="STRING"/> <property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/> </filter> <send> <endpoint> <address uri="http://localhost:9764/jaxrs_basic/services/customers/customerservice/customers" format="pox"/> </endpoint> </send> </inSequence> <outSequence> <property name="messageType" value="text/xml" scope="axis2"/> <send/> </outSequence> </target> <description/> </proxy>
Step 3 :-
Create a soap ui project for CustomerServiceProxy with the endpoint url defined in Service dashboard(as shown in below screenshot)
According to my setup, this is the endpoint url
https://madura:8243/services/CustomerServiceProxy
Step 4 :-
Send the below sample soap request using soap ui.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <getCustomer> <id>123</id> </getCustomer> </soapenv:Body> </soapenv:Envelope>
You will get the soap response as show in below screenshot.
Response with soap headers
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <Customer> <id>123</id> <name>John</name> </Customer> </soapenv:Body> </soapenv:Envelope>
Note :- I'm sending a rest resource request in the 2nd step. If you want to send only xml request, Please remove filter tags and send it in POST method.
Comments
Post a Comment