SOAP PHP正在转换'<'到'<'

时间:2015-12-17 15:54:12

标签: php xml soap

我们的SOAP请求不起作用,因为似乎SOAP正在将我们的XML字符串转换为<>

$client = new SoapClient("https://some-test-url/xxx.asmx?wsdl", array('trace' => true) );
    $soapparams = array (
        "UserName" => 'uname',
        "Password" => 'pword',
        "GroupID" => 1,
        "xmlstring" => '
        <![CDATA[
         <DocumentElement>
          <tbl>
            <var1>Q</var1>
            <var2>W</var2>
            <var3>E</var3>
          </tbl>  
        </DocumentElement>
        ]]>
        '
    );

    $response = $client->__soapCall('functionHere', array($soapparams));

$raw_request_header = $client->__getLastRequestHeaders();
$raw_request_body = $client->__getLastRequest();
$raw_response_body =  $client->__getLastResponse();

echo "<br /><br />Raw Request: ";
    echo "<code>";
    print htmlentities($raw_request_body);
    echo "</code>";

我得到了这个:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
    <SOAP-ENV:Body>
        <ns1:functionHere>
            <ns1:UserName>uname</ns1:UserName>
            <ns1:Password>pword</ns1:Password>
            <ns1:GroupID>1</ns1:GroupID>
            <ns1:xmlstring>
                 &lt;![CDATA[
                 &lt;DocumentElement&gt;
                 &lt;tbl&gt;
                 &lt;var1&gt;Q&lt;/var1&gt;
                 &lt;var2&gt;W&lt;/var2&gt;
                 &lt;var3&gt;E&lt;/var3&gt;
                 &lt;/tbl&gt; 
                 &lt;/DocumentElement&gt;
                 ]]&gt;
             </ns1:xmlstring>
        </ns1:functionHere>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

如何防止这种情况发生?我希望有人可以帮助我们。

0 个答案:

没有答案