dongrui6787 2014-03-08 15:18
浏览 49
已采纳

PHP soapCall生成不需要的htmlEntities

My PHP code tries to communicate with a Web Service.

I want to send: <ns1:in0><![CDATA[<node>

But PHP sends: <ns1:in0>&lt;![CDATA[&lt;node&gt;

If I send the <-version request in SoapUI, it works fine.

If I send the &lt;-version request in SoapUI, it returns error.

My code (without private info):

    <?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:
";
    var_dump($result);
    echo "
************************
";
    echo "REQUEST:
" . $soapClient->__getLastRequest();
    echo "
************************
";
    echo "REQUEST HEADERS:
" . $soapClient->__getLastRequestHeaders();
    echo "
************************
";
    echo "RESPONSE:
" . $soapClient->__getLastResponse();
    echo "
************************
";
    echo "RESPONSE HEADERS:
" . $soapClient->__getLastResponseHeaders();
    echo "
************************
";
    ?>

My code runs:

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

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

Someone can tell me how to send the request without html entities?

Thanks

More info:

I can not use NuSOAP

I tried:

$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));

But it wasn't a solution.

  • 写回答

1条回答 默认 最新

  • dro59505 2014-03-09 21:02
    关注

    I send request without CDATA (i.e. <ns1:in0>&lt;node&gt;) and it works fine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形