API Gateway 10.11 | Using API Gateway | APIs | SOAP to REST Transformation | Samples for REST Request
 
Samples for REST Request
application/json
The following table provides the samples of the REST request for the application/json content-type application and the equivalent SOAP request after transformation from REST to SOAP:
Request
Equivalent SOAP Request
Consists of only one element (qualified namespaces)
{
"name":"user1"
}
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://ws.apache.org/axis2">
<soapenv:Body>
<axis:sayHello>
<axis:name>user1/axis:name>
</axis:sayHello>
</soapenv:Body>
</soapenv:Envelope>
Consists of only one element (non-qualified namespaces)
{
"name":"user1"
}
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://ws.apache.org/axis2">
<soapenv:Body>
<axis:sayHello>
<name>user1</name>
</axis:sayHello>
</soapenv:Body>
</soapenv:Envelope>
Consists of multiple elements
{
"a":"1",
"b" : 2
}
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<addInts>
<a>1</a><b>2</b>
</addInts>
</soapenv:Body>
</soapenv:Envelope>
application/xml and text/xml
The following table provides the samples of the REST request for the application/xml and text/xml content-type application and the equivalent SOAP request after transformation from REST to SOAP:
Request
Equivalent SOAP Request
Consists of only one element and namespace added by the client
<axis:name xmlns:
axis=
"http://ws.apache.org/axis2"
>user1</axis:name>
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://ws.apache.org/axis2">
<soapenv:Body>
<axis:sayHello>
<axis:name>user1</axis:name>
</axis:sayHello>
</soapenv:Body>
</soapenv:Envelope>
Consists of only one element and client does not send the Namespace
<someOtherNamespace
:name xmlns:toMed=
"http:
//someOtherNamespace"
>user1
</someOtherNamespace
:name>
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://ws.apache.org/axis2">
<soapenv:Body>
<axis:sayHello>
<axis:name>user1</axis:name>
</axis:sayHello>
</soapenv:Body>
</soapenv:Envelope>
Consists of only one element and the client sends a different namespace to API Gateway
<toMed:name xmlns:
toMed="http://tOMed"
>user1</toMed:name>
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://ws.apache.org/axis2">
<soapenv:Body>
<axis:sayHello>
<axis:name>user1</axis:name>
</axis:sayHello>
</soapenv:Body>
</soapenv:Envelope>
Multiple XML elements
<addInts>
<a>2</a>
<b>3</b>
</addInts>
<soapenv:Envelope xmlns:soapenv=
"http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<addInts>
<a>2</a><b>3</b>
</addInts>
</soapenv:Body>
</soapenv:Envelope>
Path and Query Parameters
The following table provides the samples of the REST request having path and query parameters and the equivalent SOAP request after transformation from REST to SOAP:
Request
Equivalent SOAP Request
Simple query or path parameter
/ws/CalcService/
add/{num1}
or
/ws/CalcService/
add?num1=10
<ws:addInts
xmlns:ws="http:test">
<num1>10</num1></ws:addInts>s
Multiple query or path parameters
/ws/CalcService/
add/{num1}/{num2}
or
/ws/CalcService/
add?num1=10&num2=3
or
/ws/CalcService/
add/{num1}&num2=3
<ws:addInts
xmlns:ws="http:test">
<num1></num1><num2></num2>
</ws:addInts>
Hierarchical elements
/ws/CalcService/add/
{num1}/anotherNumber/{num2}
/ws/CalcService/
add/{num1}/
anotherNumber/{num2}
<ws:addInts
xmlns:ws="http:test">
<num1></num1> <num2></
num2></ws:addInts>
multipart/form-data
If you send the multipart/form-data content-type as the REST request, then you have to optimize the method to be used. This optimization is based on the value specified in the SOAP Optimization Method parameter available in Routing policy. The default optimization type is Message Transmission Optimization Mechanism (MTOM). For example, API Gateway converts REST requests with multipart/form-data and multipart/mixed types as follows:
1. The Multipurpose Internet Mail Extensions (MIME) parts that have a content ID or name that match the elements of type base64Binary or hexBinary in the schema are added as attachments to the outbound request.
2. Parts other than the content ID or name types are converted into XML depending on the content-type of the MIME part. The application/xml and application/json content-types are converted. If API Gateway is unable to process the MIME part, it wraps the MIME part inside an XML element with the name of the content ID.