PHP soapCall生成不需要的htmlEntities

时间:2014-03-08 15:18:59

标签: php xml soap-client webservice-client html-entities

我的PHP代码尝试与Web服务进行通信。

我想发送:<ns1:in0><![CDATA[<node>

但PHP发送:<ns1:in0>&lt;![CDATA[&lt;node&gt;

如果我在SoapUI中发送<-version请求,它可以正常工作。

如果我在SoapUI中发送&lt;-version请求,则会返回错误。

我的代码(没有私人信息):

    <?php
    $wsdl_path='https://....wsdl';
    $ws_path='https://...';
    $var='<![CDATA[<node>
             <subnode1>
             ...
             </subnoden>            
             </node>]]>';
    $methodName='methodName';

    $soapClient = new SoapClient($wsdl_path,array('location'=>$ws_path,'trace'=>true,'exceptions'=>false));
    $result = $soapClient->__soapCall($methodName,array(array("in0"=>($var))));

    echo "RESULT:\n";
    var_dump($result);
    echo "\n************************\n";
    echo "REQUEST:\n" . $soapClient->__getLastRequest();
    echo "\n************************\n";
    echo "REQUEST HEADERS:\n" . $soapClient->__getLastRequestHeaders();
    echo "\n************************\n";
    echo "RESPONSE:\n" . $soapClient->__getLastResponse();
    echo "\n************************\n";
    echo "RESPONSE HEADERS:\n" . $soapClient->__getLastResponseHeaders();
    echo "\n************************\n";
    ?>

我的代码运行:

RESULT:
object(stdClass)#2 (1) {
  ["out"]=>
  NULL
}

************************
REQUEST:
<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://..."><SOAP-ENV:Body><ns1:methodName><ns1:in0>&lt;![CDATA[&lt;node&gt;
         &lt;subnode1&gt;
         ...
         &lt;/subnoden&gt;            
         &lt;/node&gt;]]&gt;</ns1:in0></ns1:methodName></SOAP-ENV:Body></SOAP-ENV:Envelope> 

************************
REQUEST HEADERS:
POST ... HTTP/1.1
Host: ...
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.25
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 783


************************
RESPONSE:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><methodNameResponse xmlns="http://..."><out xmlns="http://..." xsi:nil="true"></out></methodNameResponse></soap:Body></soap:Envelope> 
************************
RESPONSE HEADERS:
HTTP/1.1 200 OK
Date: ...
Server: Apache/2.2.15  HP-UX_Apache-based_Web_Server (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/0.9.8o
X-Powered-By: Servlet/2.4 JSP/2.0
Connection: close
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8

************************

有人可以告诉我如何在没有html实体的情况下发送请求吗?

由于

更多信息:

我不能使用NuSOAP

我试过了:

$soapClient = new SoapClient($wsdl_path,array('location'=>$ws_path,'trace'=>true,'use' => SOAP_LITERAL,'style' => SOAP_DOCUMENT,'exceptions'=>false));
$params = new SoapVar($var, XSD_ANYXML);
$result = $soapClient->$methodName(array($params));

但这不是一个解决方案。

1 个答案:

答案 0 :(得分:2)

我发送没有CDATA的请求(即<ns1:in0>&lt;node&gt;),它运行正常。