nusoap服务器的响应是这样的正常吗?
如果不是,我如何修复或删除<和>,并使其成为<和>
<?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);发布于 2014-05-27 07:56:58
从这个Nusoap use existing WSDL how to?
我发现了这个
var $methodreturnisliteralxml = false;,并在创建nusoap服务器时将其设置为true。
$this->server->methodreturnisliteralxml = true;发布于 2014-05-26 11:17:29
array('return' => 'xsd:string')输出是字符串,而不是xml-结构。必须对XML中的字符串进行编码。如果您想返回其他数据,则必须使用ComplexType。看看这个问题:PHP Web Service NuSOAP complex type
示例:
$this->server->wsdl->addComplexType(/** definition **/);
$this->server->register('get_stocks', // method name
array('product' => 'xsd:int'), // input parameters
array('return' => 'tns:yourComplexType'), // output parameters就像@butching说的,你也有一个编码错配,这是不好的,但不是你的问题的原因。
https://stackoverflow.com/questions/23867128
复制相似问题