PHP Development Experience Two

Source: Internet
Author: User

How to fix the error: PHP SOAP Fatal error:uncaught soapfault exception: [Client] looks like we got no XML document?

The following code is present, and the above error occurs at run time. The reason is also clear, because __soapcall expects to return data in XML format, and if not, an error occurs.

    $webservice _url = "Http://120.25.XX. Xx:3000/service.asmx? WSDL ";//webservice address    $client = new Soapclientnew ($webservice _url); try{    $arr = $client->__soapcall (' Functionsql ', Array (' parameters ' = + $param));//Call the method}catch (Exception $e) {echo $e. getMessage ();}

  

So, what if the JSON data returned by our web service call is unusable? Online check, combined with personal groping, the following ways can bypass this problem, better solve.

1, create a new class Soapclientnew extends SoapClient {public   function __dorequest ($request, $location, $action, $version, $ One_way = 0) {   $request = parent::__dorequest ($request, $location, $action, $version, $one _way); $GLOBALS [' $soap _ Call_result '] = $request; Important! The result has been returned here, saved to the global variable//$start = Strpos ($request, ' <soap ');//According to the actual situation to do processing ... , if it is <?xml start, change to <?xml//$end = Strrpos ($request, ' > '); Return substr ($request, $start, $end-$start + 1);     return $request; }}2, calling the new class $client = Soapclientnew ($webservice _url);  try{   $arr = $client->__soapcall (' Functionsql ', Array (' parameters ' = = $param));//Call one of the methods  }catch ( Exception $e) {  }    $arr = $GLOBALS [' $soap _call_result '];//After the call to read the global variable, you can get the result of the call Print_r ($arr);  

  

PHP Development Experience Two

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.