Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php simplexml_load_string()给出错误,因为SOAP响应被传递为而不是_Php_Web Services_Soap - Fatal编程技术网

Php simplexml_load_string()给出错误,因为SOAP响应被传递为而不是

Php simplexml_load_string()给出错误,因为SOAP响应被传递为而不是,php,web-services,soap,Php,Web Services,Soap,嘿,伙计们,我正在尝试创建一个简单的web服务,用户在文本框中输入价格,然后查询数据库并返回与价格相对应的衣服名称,但当我尝试在simplexml加载字符串中传递soap响应时,我遇到了一个错误;。这是我收到的错误快照: 以下是我的client.php代码: <?php if(isset($_POST['search_input'])) { try { $input = $_POST['search_input']; $wsdl = "http://localhost/

嘿,伙计们,我正在尝试创建一个简单的web服务,用户在文本框中输入价格,然后查询数据库并返回与价格相对应的衣服名称,但当我尝试在simplexml加载字符串中传递soap响应时,我遇到了一个错误;。这是我收到的错误快照:

以下是我的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$响应;结果:

objectstdClass2 1{[DressPerPrice]=>array5{[0]=> objectstdClass3 3{[Name]=>string7连衣裙2[Price]=> int20[Image]=>string24}=>objectstdClass4 3{ [Name]=>string7连衣裙9[Price]=>int20[Image]=> string6 3.jpeg}[2]=>objectstdClass5 3{[Name]=> string8连衣裙10[价格]=>int20[图像]=>string19 0905C58A0179_1.jpeg}[3]=>objectstdClass6 3{[Name]=> string8连衣裙11[价格]=>int20[图像]=>string19 0905C58A0179_1.jpeg}[4]=>objectstdClass7 3{[Name]=> string8连衣裙12[价格]=>int20[图像]=>string19 0905C58A0179_1.jpeg}} 连衣裙 220件连衣裙 9203.1件连衣裙 10200905C58A0179_1.jpeg 11200905C58A0179_1.jpeg 12200905C58A0179_1.jpeg

有什么办法可以解决这个问题吗?
非常感谢你的帮助。谢谢。

我想您可能希望将$response传递给simplexml_load_字符串,而不是HTMLSpecialChars的$soapresponse。当我传递$response时,它会给我传递一个对象而不是字符串的错误。那么,$client->viewDressPerPrice$input;到底返回了什么;?你能把$response变为var_dump吗;并分享结果?是的,我确实编辑了这个问题。没有wsdl,我已经有点猜测了,但是你能试着在$client->\uu getLastResponse上不使用htmlspecialchars吗?