php - 解析 SOAP 负载的 XML 错误 : Reserved XML Name

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

我可以毫无问题地查看 WSDL(内部/防火墙后,因此没有提供链接)。

这是调用我的方法后 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 没有受到保护,因为它是内部/测试。

最佳答案

去掉<?xml之前的空格和 then it works .如果不能,也许您可​​以将 nusoap 类更改/扩展为 trim解释前的 react 。额外的空格很可能来自 <?php 之外的一些意外空格& ?>标签。

https://stackoverflow.com/questions/11107592/

相关文章:

haskell - 包含不同类型的列表

mysql - SQL select count for more than one like

assembly - 为什么我们可以在16位模式下使用eRx,而在32位模式下不能使用rRx?

encryption - 解码 AES-256 key 需要多少种组合?

php - 如何从一个函数返回多个值

sql - 更新引用另一个表

sql-server - 普通的 SQL Server 索引是否包含主键值?

php - 从php中的日期检索日期,月份,年份

mongodb - 为什么叫NoSQL?

vba - Access 自定义组