Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solution of PHP SOAP error: looks like we got no XML document
// Source: http://www.highonphp.com/fixing-soap-exception-no-xml
class SoapClientNG extends \SoapClient{
public function __doRequest($req, $location, $action, $version = SOAP_1_1){
$xml = explode("\r\n", parent::__doRequest($req, $location, $action, $version));
$response = preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $xml[0] );
return $response;
}
}
// Source: http://stackoverflow.com/questions/14319696/soap-issue-soapfault-exception-client-looks-like-we-got-no-xml-document
function strip_bom( $str ) {
return preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $str );
}
@braianj

This comment has been minimized.

Copy link

commented Dec 18, 2018

how to use it?

@SicorDev

This comment has been minimized.

Copy link

commented May 24, 2019

My php wants this declaration:

class SoapClientNG extends \SoapClient{

public function __doRequest($request, $location, $action, $version = SOAP_1_1, $one_way = null){

...

}

}

@SicorDev

This comment has been minimized.

Copy link

commented May 24, 2019

how to use it?

Just put above class code in your php where you want to use SoapClient and then use SoapClentNG instead of SoapClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.