解析 SOAP 负载的 XML 错误:保留的 XML 名称 [英] XML error parsing SOAP payload: Reserved XML Name

查看:29
本文介绍了解析 SOAP 负载的 XML 错误:保留的 XML 名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a very simple web service that returns a string (hardcoded at that). I keep getting an error while parsing SOAP payload : Reserved XML Name.

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

I can view the WSDL no problem (interal/behind firewall, so no link to provide).

这是调用我的方法后 NuSOAP 客户端的部分转储:

Here's a partial dump of the NuSOAP client after having called my method:

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 服务返回的硬编码内容:

In the SOAP body, you can see "SomeText" which is the hard coded content that is returned from my web service that contains only one method:

$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 不受保护,因为它是内部/测试端口.

In my case, port 443 isn't protected as it's internal/testing.

推荐答案

去除 <?xml然后它工作.如果不能,也许您可​​以在解释之前更改/扩展 nusoap 类以 trim 响应.额外的空白很可能来自 <?php & 之外的一些意外空白.?> 标签.

Remove the whitespace before <?xml and then it works. If you can't, maybe you can alter/extend the nusoap class to trim the response before interpretation. Most likely the extra whitespace comes from some accidental whitespace outside the <?php & ?> tags.

这篇关于解析 SOAP 负载的 XML 错误:保留的 XML 名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆