简体   繁体   中英

Read UTF-8 SOAP request through php://input

I'm working on a simple listener for an external node talking SOAP to it. In addition to simple requests, node sends MultiPart messages as well, hence not allowing me to use any PHP SOAP libraries (if you know of any dealing with MultiPart messages, please let me know) and forcing me to work with raw data from the request body, namely php://input . No problems with it, except for UTF-8 support.

PHP is very simple at the moment:

mb_internal_encoding('UTF-8');
echo file_get_contents('php://input');

When ñ is sent towards node for example, node will send following to the listener:

...
<message>}</message>
...

Another example are latin characters, for example č ć š đ ž Č Ć Š Đ Ž are sent as

...
<message>c c s d z C C S D Z</message>
...

tcpdump shows request is sent in UTF-8, however XML still contains invalid characters:

POST /endpoint HTTP/1.0
Content-Type: text/xml; charset=UTF-8
SOAPAction: ""
User-Agent: Axis2
Host: IP:PORT
Content-Length: 1196

<?xml version='1.0' encoding='UTF-8'?>
...
<message>}</message>
...

Assuming node is properly encoding data, what can I do on my end to figure out what is wrong?

After several testing sessions it was determined the node is not sending UTF-8 encoded data, even though the request itself is sent in UTF-8. There is no ETA on when it will be fixed :(

Good news, however, php://input handles UTF-u properly!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM