cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding Content type application/x-www-form-urlencoded in HTTP Adapter

Former Member
0 Kudos

Hi,

I am posting messages to a webserver using HTTP Adapter. The target webserver accepts the content type application/x-www-form-urlencoded only.

I have set this content type in HTTP Receiver adapter parameter.

My doubt is that whether the parameter is just used to set the content type in header of the HTTP Post or the HTTP adapter actually encodes the message using form url encoding. I have this doubt becoz some chars like '+' and '£' are not encoded properly and i have manually repleced their values with their respecting UTF-8 URL encoded values using java code.

Thanks in advance.

Regards,

Sudharshan N A

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

...or the HTTP adapter actually encodes the message using form url encoding.

No. The payload is sent "as is".

I have this doubt becoz some chars like '+' and '£' are not encoded properly and i have manually repleced their values with their respecting UTF-8 URL encoded values using java code.

+ and £ are UTF-8 characters, so you need not do anything here.

Former Member
0 Kudos

Stefan,

Thanks for the information. I have the following question then.

The Webserver I am interacting with does not recognize user and password provided in the channel. It accepts user and pwd in payload and in application/x-www-form-urlencoded content type only.

Sample Raw Post that server server requires looks like this

User=yourname&Password=yourpassword&INPUT_XML=%3C%3Fxmlversion%3D%221.0%22standalone%3D%22no%22%3F%3E%3CDELIVERY%3E%3CMESSAGE%3E%0D%0A++++%3CDESTINATION_ADDR%3E%2B447900570205%3C%2FDESTINATION_ADDR%3E%%3C%2FMESSAGE%3E%0D%0A%0D%0A%3C%2FDELIVERY%3E%

What i have done is that constructed the post manually in Java code in un encoded form and expected the HTTP Adapter to do the encoding. Having done this, the HTTP Server is able to scuccessfully parse the xml except for & and < , > chars which err out as invalid XML.

Is there an elegant way of doing above scenario using XML post and standard HTTP Adapter.

Best Regards,

Sudharshan N A

stefan_grube
Active Contributor
0 Kudos

> Is there an elegant way of doing above scenario using XML post and standard HTTP Adapter.

No. There is no easy way to do this with any PI adapter.

I recommend using a Java Proxy for this request.

Former Member
0 Kudos

Stefan,

Thanks for your valuable inputs.

The problem i am facing is that the XML of the post has <Text></Text> field. I am unable to send &,<,> symbols. Strangely I am able to send ' , " symbols in escaped and unescaped form. I tried CDATA sections and &amp; and &lt;,etc. But no luck. The WebServer rejects the request as invalid XML. I have given encoding as UTF-8 in my XML prolog and also content Encoding as UTF-8 in HTTP Adapter. I even tried SOAP adapter without Envelope, both of them show the same behavior.

The 3rd party WebServer encoding is set to accept UTF-8 and all other encodings.

Regards,

Sudharshan N A

stefan_grube
Active Contributor
0 Kudos

You can use a Java mapping like in that code for escaping the characters: