Hi,
I have JAX-RS service which I am trying to access via an API in the APIM.
I am experimenting, sending a request to the service *(which accepts a JSON
payload)* via *"telnet"*. I found the following behaviour when I was doing
this:
---------------------------------------------------------------------
When I send a *POST* message to the service directly (NOT via the API) the
request gets accepted fine and I get a reply *"204 No Content" *which is
correct.
*The message I sent and the reply via telnet in this scenario is this:*
localhost:~ xxxxxxxxxxx$ telnet localhost 9763
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /sensebot/controller/pushsensordata HTTP/1.1
Host: localhost:9763
Content-Type: application/json
Content-Length: 86
{"owner":"shabirmean","deviceId":"1hblhgfxlpffo","reply":"Data","value":"27:10:-1:39"}
HTTP/1.1 204 No Content
Date: Thu, 11 Jun 2015 18:29:35 GMT
Server: WSO2 Carbon Server
---------------------------------------------------------------------
Next I sent the same *POST *message to the service *via an API in the APIM.*
*The reply via telnet in this scenario is this:*
localhost:~ xxxxxxxxxx$ telnet localhost 8281
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /sensebotdata/1.0/controller/pushsensordata HTTP/1.1
Host: localhost:8281
Content-Type: application/json
Content-Length: 86
{"owner":"shabirmean","deviceId":"1hblhgfxlpffo","reply":"Data","value":"27:10:-1:39"}
HTTP/1.1 204 No Content
Date: Thu, 11 Jun 2015 18:28:42 GMT
Server: WSO2-PassThrough-HTTP
HTTP/1.1 400 Bad request
Connection: Close
Date: Thu, 11 Jun 2015 18:28:42 GMT
Server: WSO2-PassThrough-HTTP
Content-Length: 0
Connection closed by foreign host.
It sends a reply for accepting the message and subsequently APIM also
replies with a "*400 Bad Request*" message and closes the connection.
I tried doing a packet analysis of both scenarios and found that in the
message that goes through the APIM, there are *"two additional random
characters" *being appended to the payload.
59
{"owner":"shabirmean","deviceId":"us09bxh21qnq","reply":"Data","value":"27:10:-1:3900"}
Having seen this I increased the *"Content-Length" *value in the header by *"2"
*and tried invoking the API. And it works like a charm.
localhost:~ smean-MAC$ telnet localhost 8281
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /sensebotdata/1.0/controller/pushsensordata HTTP/1.1
Host: localhost:8281
Content-Type: application/json
Content-Length: 88
{"owner":"shabirmean","deviceId":"1hblhgfxlpffo","reply":"Data","value":"27:10:-1:39"}
HTTP/1.1 204 No Content
Date: Thu, 11 Jun 2015 18:29:02 GMT
Server: WSO2-PassThrough-HTTP
---------------------------------------------------------------------
I have no clue to how/why these two additional characters are being
appended at the APIM end. This is not to be seen when I directly call the
service.
Am I missing something important here? Is there any specific reason for
this behaviour?
Thanks In Advance!
-------------------------------------
*Shabir Mohamed*
*Software Engineer*
WSO2 Inc.; http://wso2.com
Email: [email protected] <[email protected]>
Mobile: +94 77 3516019 | +94 71 6583393
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev