How to Solve Soapserver Error: ”looks like we got no XML document“

 

Due to the version problem, there may be an error in uncaught soapfault exception: [Client] looks like we got no XML document. One of the reasons is that when sending and receiving, a warning is sent together with the data, resulting in a format error

When I used PHP to write soapserver, I couldn’t get the return value correctly. I found several solutions on the Internet, but they didn’t work until someone reminded me that there was something wrong with the data sent, so I could select the data manually

Rewrite

classSoapClientNewextendsSoapClient
{
publicfunction__doRequest($request,$location,$action,$version,$one_way=0)
{
$request=parent::__doRequest($request,$location,$action,$version,$one_way);

$start=strpos($request,'<soap');//Do the processing according to the actual situation.... , if it starts with <?xml, change it to <?xml
$end=strrpos($request,'>');
returnsubstr($request,$start,$end-$start+1);
}
}

Call

$client=newSoapClientNew($url);

can solve the problem

add a few lines to the code,

classSoapClientNewextendsSoapClient
{
publicfunction__doRequest($request,$location,$action,$version,$one_way=0)
{
$request=parent::__doRequest($request,$location,$action,$version,$one_way);

$myfile=fopen("newfile.txt","w")ordie("Unabletoopenfile!");
$txt=$request;
fwrite($myfile,$txt);
fclose($myfile);

$start=strpos($request,'<?xml');//Do the processing according to the actual situation.... , if it starts with <?xml, change it to <?xml
$end=strrpos($request,'>');
returnsubstr($request,$start,$end-$start+1);
}
}

it can be found that the data to be sent generated by the function becomes

<br/>
<b>Deprecated</b>:Automaticallypopulating$HTTP_RAW_POST_DATAisdeprecatedandwillberemovedinafutureversion.Toavoidthiswarningset'always_populate_raw_post_data'to'-1'inphp.iniandusethephp://inputstreaminstead.in<b>Unknown</b>online<b>0</b><br/>
<br/>
<b>Warning</b>:Cannotmodifyheaderinformation-headersalreadysentin<b>Unknown</b>online<b>0</b><br/>
<?xmlversion="1.0"encoding="UTF-8"?>
<SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ns1="http://localhost/zlf/server.php"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:sayhelloResponse><returnxsi:type="xsd:string">hello!zlfamazing</return></ns1:sayhelloResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

the front warning is the cause of soap error. In addition to appeal settlement, follow the prompts to add always in php.ini file_ populate_ raw_ post_ If the semicolon in front of data = - 1 is removed and warning disappears, the problem of error reporting can also be solved

Similar Posts: