Reputation: 21
I've been using trying out the WSO2 API Manager 3.2.0 to generate REST APIs for a SOAP web service and have successfully traversed the procedures. I enabled message wire tracing in order to view the requests-responses in the logs. I can see that a correctly formatted message is being created and sent to the back end service, however, the response is not as expected. I've noticed some extra text (usually "16e" as in the second to last line) is sent just before the XML payload and is therefore being processed as the payload. I suspect that it's the cause of my problems, but I am unable to trace where it originates.
TID: [-1] [] [2021-05-12 15:23:55,792] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "POST /services/services.php HTTP/1.1[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,792] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Origin: https://api-manager.ug.com:9443[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,792] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "SOAPAction: https://testservices.ug.com/services/services.php/GetAccountBalance_2[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,792] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "activityID: 119801787388364143641044[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,792] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Accept: application/json[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,792] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Referer: https://api-manager.ug.com:9443/[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "testkey: 76d33583-e7f9-42a3-a4ad-d91118f8b043[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Accept-Language: en-US,en;q=0.5[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "DNT: 1[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Content-Type: application/soap+xml[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Transfer-Encoding: chunked[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Host: testservices.ug.com[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "Connection: Keep-Alive[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,793] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "16e[\r][\n]"
TID: [-1] [] [2021-05-12 15:23:55,794] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-5 << "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://testservices.ug.com/soap/TransactionServices"><soapenv:Body><web:GetAccountBalance_2><AccountNumber>001221131211</AccountNumber><AuthToken>111111</AuthToken></web:GetAccountBalance_2></soapenv:Body></soapenv:Envelope>[\r][\n]"
When I use the XML request and call the back end SOAP service directly, I get a successful response. Any idea what could be responsible for this text and what I need to do to get rid of it? Your help will be appreciated.
Upvotes: 0
Views: 119
Reputation: 21
I got the source of the 16e from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding#directives
chunked
Data is sent in a series of chunks. The Content-Length header is omitted in this case and at the beginning of each chunk you need to add the length of the current chunk in hexadecimal format, followed by '\r\n' and then the chunk itself, followed by another '\r\n'. The terminating chunk is a regular chunk, with the exception that its length is zero. It is followed by the trailer, which consists of a (possibly empty) sequence of entity header fields.
The problem turned out to be the content-type. I was sending the value "application/soap+xml" and changed that to "text/xml" by adding the line below in the xml config file for the api found in <CARBON_HOME>/repository/deployment/server/synapse-configs/default/api/
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
That's all that was required to make it work.
Upvotes: 2