2012-06-19 55 views
1

我有一个非常简单的Web服务,它返回一个字符串(硬编码)。我在分析SOAP有效负载时不断收到错误:保留的XML名称。XML错误分析SOAP有效负载:保留的XML名称

我可以查看WSDL没有问题(interal /后面的防火墙,所以没有链接提供)。

这里的的NuSOAP客户端的部分转储已经打电话给我的方法后:

public 'request' => string 'POST myinternalhost.ca/ws.php HTTP/1.0 
Host: myinternalhost.ca:443 
User-Agent: NuSOAP/0.7.3 (1.114) 
Content-Type: text/xml; charset=ISO-8859-1 
SOAPAction: "" 
Content-Length: 510 

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="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="htt'... (length=716) 

public 'response' => string 'HTTP/1.1 200 OK 
Date: Tue, 19 Jun 2012 18:43:10 GMT 
Server: Apache/2.0.59 (Win32) DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.8e mod_auth_sspi/1.0.4 PHP/5.2.3 
X-Powered-By: PHP/5.2.3 
X-SOAP-Server: NuSOAP/0.7.3 (1.114) 
Content-Length: 470 
Connection: close 
Content-Type: text/xml; charset=ISO-8859-1 

    <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope 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-i'... (length=769) 

    public 'responseData' => string ' <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope 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/"><SOAP-ENV:Body><ns1:vms_ws_list_filesResponse xmlns:ns1="http://tempuri.org"><return xsi:type="xsd:string">SomeText</return></ns1:vms_ws_list_filesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>' (length=470) 

public 'error_str' => string 'XML error parsing SOAP payload on line 1: Reserved XML Name' (length=59) 

在SOAP身上,你可以看到“SomeText”则会这是从我的Web服务返回的硬编码的内容,包含只有一个方法:

$server->register('vms_ws_list_files', 
    array('password' => 'xsd:string'),  // Password check 
    array('return' => 'xsd:string'),  // Output parameters 
    $ns,         // namespace 
    $ns . '#vms_ws_list_files',     // soapaction 
    'rpc',        // style 
    'encoded',       // use 
    'Get list of files on disk'      // documentation 
); 

... 

function vms_ws_list_files($password){ 
    global $site; 
    // Check password 
    if ($password != 'myHardCodedPwdForTesting') { 
     return new soap_fault('Wrong password!', '', ''); 
    } 
    $out = "SomeText"; 

    return $out; 
} 

在我的情况下,端口443不受保护,因为它是内部/测试。

+0

你不能使用PHP Soap扩展吗? SOAPServer和SOAPClient? http://php.net/manual/en/book.soap.php – Dharmavir

回答

6

删除<?xmlthen it works之前的空格。如果你不能,也许你可以在解释之前修改/扩展nusoap类到trim。最有可能的是,额外的空格来自<?php & ?>标签之外的一些意外空白。

+0

谢谢!只要我清理了白色空间并刷新了一切,这一切都完美无瑕。 – TekiusFanatikus

5

添加在nusoap.php以下行:

$这 - > responseData =修剪($这个 - > responseData);此行之前

返回$这 - > parseResponse($ HTTP-> incoming_headers,修剪($这个 - > responseData));

解决了我同样的问题

+0

Thanx.your答案解决了我的问题。 – AndyN

+0

这对我有用,谢谢,干得好。 – Matt

0

在我的代码它是格式不正确XML,如葡萄牙语BR具有非常特殊字符,引号,没有正确关闭标签。在代码的结尾显示返回XML,在此网站上进行检查:http://www.xmlvalidation.com/ 然后他又回到工作。