【发布时间】:2014-05-26 09:36:46
【问题描述】:
nusoap服务器的响应是这样的正常吗?
如果没有,我该如何修复或删除 &lt 和 &gt 并使其成为 < 和 >
<?xml version="1.0" encoding="utf-8"?>
<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="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:get_stocksResponse xmlns:ns1="VSR"><return xsi:type="xsd:string"><facilitator>
<stock_response>
<product>
<productid>1072722</productid>
<voorraad>888040</voorraad>
</product>
<product>
<productid>1072724</productid>
<voorraad>888603</voorraad>
</product>
</stock_response>
</facilitator>
</return></ns1:get_stocksResponse></SOAP-ENV:Body></SOAP-ENV:Envelope></code>
这是我在服务器中的注册功能
$this->server->register('get_stocks', // method name
array('product' => 'xsd:int'), // input parameters
array('return' => 'xsd:string'), // output parameters
$this->_namespace, // namespace
'urn:'.$this->_namespace.'#get_stocks', // soapaction
'rpc', // style
'encoded', // use
'Get stocks of products' // documentation
);
这是我的返回函数
$xmlDoc = new DOMDocument('1.0', 'utf-8');
$xmlDoc->formatOutput = TRUE;
...etc
$nodes = $xmlDoc -> getElementsByTagName ('facilitator');
$node = $nodes -> item(0);
return $xmlDoc->saveXML($node);
【问题讨论】:
-
您在 XML 文档中返回转义的 XML:
<return xsi:type="xsd:string">- 转义的 字符串 是String,而不是 XML 结构。我猜你实施错了。 -
那应该是什么?谢谢
-
检查你的字符编码!您的返回 XML 是 encoding="ISO-8859-1" 但您的返回函数是 utf-8
-
我修复了编码但仍然没有解决问题,谢谢顺便说一句