Localhost上的NuSOAP服务响应

时间:2016-06-01 18:40:17

标签: c# php soap

我在使用NuSOAP API时遇到了一些问题。我有一个.NET Core应用程序通过发布正确的XML信封来调用此API,如下所示:

Uri uri = new Uri(ServiceConfiguration.SERVICE_URL);

HttpClient hc = new HttpClient();

hc.DefaultRequestHeaders.Add("SOAPAction", ServiceConfiguration.SERVICE_URL + "/" + oRequest.Action);

   var content = new StringContent(oRequest.RequestMessage, Encoding.UTF8, "text/xml");

   using (HttpResponseMessage response = await hc.PostAsync(uri, content))
            { 
             (...) 
            }

所以基本上这是发布带有SOAP请求的XML Envelope。如果我在我的计算机上运行它并调用远程NuSOAP API,我得到正确的响应 - >带有SOAP响应的XML。问题是如果我的PC上也运行了NuSOAP API(都是本地主机)我得到了一个非常奇怪的响应(加载了奇怪的符号)。

当NuSOAP是localhost时我得到的响应(不行 - XML无效)

"<br />\n<b>Deprecated</b>:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b></b> on line <b>3</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b></b> on line <b>4</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b></b> on line <b>5</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b></b> on line <b>6</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b></b> on line <b>4272</b><br />\n<br />\n<b>Warning</b>:  Cannot modify header information - headers already sent in <b>C:\\Wamp64\\www\\teek_api\\lib\\nusoap.php</b> \u001f�\b\0\0\0\0\0\0\v�Uao�0\u0010�+Q>��B�@\vx��2����N��)r�k�j��v�t�\u007f��$\u0014\u0013��\u0012\u0012��\u07bb���1:}Xro\u0005J3)N|ԉ|\u000f\u0004�)\u0013ى\u007f��<\u0018�������[0���gb\u0005\\��m#\rzn6\u001cN��19\u000eCM\u0017�$�cյ$yG�,,\u001f�\u0006\u001e��=\u0013\u001a7Bo�V���\a�nY�����>��(B��ˋ���\v��\u001f\u001c0�\r\u0011\u0014������\u001d��d�\u0019��F�Р.d��5�\\\n\ru\u0002{����#\u0005�P³�`�ɭ��\u0005�������\u000f\u007f\ni>��RbH�\v�Q�&�A\u001d��\u0010�V\u000f\u001f_��,�\u0001]3JT*���\u0003��2� U��(\v����\u001d*�\u000eIAƴ\u0001��\u0002�4q���(\u000e⁇�p\u0017���ar�M�r��1jcx��\u0001i�A\u001e\u001a�8Ʊ�v\u0006\"�s&r\0T\nC��\u0011��|׃�\u000e\u0010�c���:\n�D�=����썩�P���)��k\u0017�v�����۰\v�\u001dٱ\u007f�&�A|T�D�è�S�T��$�k�e�,ښh8\u0018\u0006Q?�])�V��Ei\u000eO�4�FJv�\u000fY)`�,Ak��~+�\u0013�\u0015�Ю�J.U�<{n�)ܑ�\u001bG�鄤Kv0�S#Xu�k̯��%J������\u0015�-��\u001e�\u001b;��]g9�F��^��lj��\u0006��� ���I0<�\u007f\t����x2=\u001b�\u0011\n��f3��մ\u001eհ�_'\u05fc�Ԇ=Jx��>=��j!�G��5g�{�0l����\u0001㙜��\u0006\0\0"

NuSOAP远程时我得到的响应(确定 - 有效的XML)

  

“http://schemas.xmlsoap.org/soap/encoding/ \”xmlns:SOAP-ENV = \“http://schemas.xmlsoap.org/soap/envelope/\”xmlns:xsd = \“http://www.w3.org/2001/XMLSchema\”xmlns:xsi = \“http://www.w3.org/2001/XMLSchema-instance\”xmlns:SOAP-ENC = \“http://schemas.xmlsoap.org/soap/encoding/\”&gt;   http://schemas.xmlsoap.org/soap/envelope/\">      (......)      “

我还不断收到“自动填充$ HTTP_RAW_POST_DATA已被弃用”,并且我已经将。strong上的 always_populate_raw_post_data 更改为-1并且我一直在获取这些内容。

1 个答案:

答案 0 :(得分:2)

我和nusoap“无效的xml”有同样的问题。我正在使用最新的php nusoap:https://sourceforge.net/projects/nusoapforphp53/用于php 5.3,但我的php版本运行5.6。 nusoap.php中使用的一些php函数已被弃用。这就是显示错误的原因。

我做的一些快速修复是:把它放在nusoap.php中,以防止显示错误

<?php 
error_reporting(0);
ini_set('display_errors', 1);

或者找到nusoap.php中弃用的命令行,并将其替换为替代。