Created
March 4, 2014 13:42
-
-
Save egulhan/9346678 to your computer and use it in GitHub Desktop.
Solution of PHP SOAP error: looks like we got no XML document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wors nicely! For me i just had to remove \n at the start.