PHP NuSOAP响应

时间:2014-05-26 09:36:47

标签: php response nusoap

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">&lt;facilitator&gt;
&lt;stock_response&gt;
    &lt;product&gt;
      &lt;productid&gt;1072722&lt;/productid&gt;
      &lt;voorraad&gt;888040&lt;/voorraad&gt;
    &lt;/product&gt;
    &lt;product&gt;
      &lt;productid&gt;1072724&lt;/productid&gt;
      &lt;voorraad&gt;888603&lt;/voorraad&gt;
    &lt;/product&gt;
&lt;/stock_response&gt;
&lt;/facilitator&gt;
</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);

2 个答案:

答案 0 :(得分:1)

来自Nusoap use existing WSDL how to?

我发现了这个

var $methodreturnisliteralxml = false;

并在创建nusoap服务器时将其设置为true

$this->server->methodreturnisliteralxml = true;

答案 1 :(得分:0)

array('return' => 'xsd:string')

输出是字符串,而不是xml-structure。 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所说,你也有一个编码不匹配,这很糟糕,但不是你问题的原因。

相关问题