simplexml_load_string()给出错误,因为SOAP响应正以<而不是<

时间:2015-04-07 16:54:17

标签: php web-services soap

嘿伙计我试图创建一个简单的Web服务,用户在文本框中输入价格,然后查询数据库并返回与价格相对应的服装名称但我得到的我尝试在simplexml_load_string();中传递soap响应时出错。这是我得到的错误的快照:

enter image description here

这是我的client.php代码:

<?php

if(isset($_POST['search_input']))
{
try
{
    $input = $_POST['search_input'];

    $wsdl = "http://localhost/WebService/UDDI/90210Store.wsdl";

    //$options = array('cache_wsdl'=>WSDL_CACHE_NONE, 'features'=>SOAP_SINGLE_ELEMENT_ARRAYS);

    //$client = new SoapClient($wsdl, $options);

    $debugOption = array('trace'=>true, 'cache_wsdl'=>WSDL_CACHE_NONE, 'features'=>SOAP_SINGLE_ELEMENT_ARRAYS);
    $client = new SoapClient($wsdl, $debugOption);

    $response = $client->viewDressPerPrice($input);

    $soaprequest = "<strong>REQUEST:</strong><br/>" . htmlspecialchars($client->__getLastRequest()) . "<br/>";
    $soapresponse = htmlspecialchars($client->__getLastResponse());

    echo $soapresponse;

    if(isset($response->DressPerPrice))
    {
        $XMLDocument = simplexml_load_string($soapresponse); //this part giving errors  
        $XSLDocument = new DOMDocument();
        $XSLDocument->load("WSEx1.xsl");
        $XSLProcessor = new XSLTProcessor();//PHP5
        $XSLProcessor->importStylesheet($XSLDocument);

       echo $XSLProcessor->transformToXML($XMLDocument);
    }

    else
    {
        echo "This field is not found in database";
    }
}

catch(Exception $e)
{
echo 'Exception: '.$e->getMessage();
}

catch(SOAPFault $exception)
{
echo 'SOAP Exception: '.$exception->getMessage();
}

}

else
{
header("Location: http://localhost/WebService/Client/Category.html");
}

?>

的var_dump($响应);结果:

  

object(stdClass)#2(1){[&#34; DressPerPrice&#34;] =&gt; array(5){[0] =&gt;   object(stdClass)#3(3){[&#34; Name&#34;] =&gt;字符串(7)&#34;连衣裙2&#34; [&#34;价格&#34;] =&GT;   int(20)[&#34; Image&#34;] =&gt;字符串(24)&#34;&#34; } 1 =&gt; object(stdClass)#4(3){   [&#34;名称&#34;] =&GT;字符串(7)&#34;连衣裙9&#34; [&#34;价格&#34;] =&GT; int(20)[&#34; Image&#34;] =&gt;   string(6)&#34; 3.jpeg&#34; } [2] =&gt; object(stdClass)#5(3){[&#34; Name&#34;] =&gt;   字符串(8)&#34;连衣裙10&#34; [&#34;价格&#34;] =&GT; int(20)[&#34; Image&#34;] =&gt;串(19)   &#34; 0905C58A0179_1.jpeg&#34; } [3] =&gt; object(stdClass)#6(3){[&#34; Name&#34;] =&gt;   字符串(8)&#34;连衣裙11&#34; [&#34;价格&#34;] =&GT; int(20)[&#34; Image&#34;] =&gt;串(19)   &#34; 0905C58A0179_1.jpeg&#34; } [4] =&gt; object(stdClass)#7(3){[&#34; Name&#34;] =&gt;   字符串(8)&#34;连衣裙12&#34; [&#34;价格&#34;] =&GT; int(20)[&#34; Image&#34;] =&gt;串(19)   &#34; 0905C58A0179_1.jpeg&#34; }}}   连衣裙   220℃; IMG   SRC =&#34; 2.jpeg&#34;&GT;&LT; / IMG&GT;着装   9203.jpegDress   10200905C58A0179_1.jpegDress   11200905C58A0179_1.jpegDress   12200905C58A0179_1.jpeg

我可以解决这个问题吗? 非常感谢您的帮助。感谢。

0 个答案:

没有答案
相关问题