简体   繁体   English

通过php:// input读取UTF-8 SOAP请求

[英]Read UTF-8 SOAP request through php://input

I'm working on a simple listener for an external node talking SOAP to it. 我正在为外部节点与SOAP进行对话的简单侦听器。 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 . 除了简单的请求之外,节点还发送MultiPart消息,因此不允许我使用任何PHP SOAP库(如果您知道任何与MultiPart消息打交道的信息,请让我知道),并迫使我使用请求中的原始数据正文,即php://input No problems with it, except for UTF-8 support. 除了UTF-8支持外,它没有任何问题。

PHP is very simple at the moment: 目前,PHP非常简单:

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: tcpdump显示请求以UTF-8发送,但是XML仍然包含无效字符:

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. 经过几次测试会话后,即使请求本身是以UTF-8发送的,该节点仍未发送UTF-8编码的数据。 There is no ETA on when it will be fixed :( 何时修复没有ETA :(

Good news, however, php://input handles UTF-u properly! 好消息是, php://input正确处理UTF-u!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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