web services - Remove BOM Character from soap response : SOAP: looks like we got no XML document -


hi beginning in creating webservices,

i'm trying create web service using soap protocol , keep getting following error:looks got no xml document.

here below web service , output of response. see i'm getting bom character () in begining of response.. think root cause of error getted specify xml not valid.please there way remove character client. i'm noticing i've tried override _dorequest method of soapclient no success. wsdl file , sever script encoded in utf-8 without bom.

any solve issue appreciated.

regards.

client:

try{     ini_set("soap.wsdl_cache_enabled", "0");// disabling wsdl cache     libxml_disable_entity_loader(false);     if(!extension_loaded("soap")){ dl("php_soap.dll");  }     $client2 = new soapclient("http://www.payafrik.com/payafrikapi.wsdl",array("wsdl_cache"=>0,"trace"=>1,"exception"=>1));     $slabrequest["email"]  = "tes@gmail.com";     $slabrequest["description"] = "test";     $slabrequest["montant"]    = 50000;     $client2->slabaccount($slabrequest); }catch(exception $e){      var_dump( $e );      echo "<pre>"; echo "request :<br/>", htmlentities($client2->__getlastrequest()), "<br/>";      echo "response :<br/>", htmlentities($client2->__getlastresponse()), "<br/>";echo "</pre>"; }    

.. output of response :  repsuccessuser4monsieurgnacadjaloic 1rue 1382littoral1229cotonou22921332680229972461401987-03-26loic.gnacadja@gmail.com646260ea6e66c61704c695e617f9b74alogin1309625000011242015-07-12 23:50:30

it's bit old question, had same issue, leave solution problem, in case directed here google :)

looks not bom, data, new lines, before xml data, make soapclient report error. clients of service, can not change message get, or server configuration.

solution worked me

by setting soapclient trace true, , calling soapclient::__getlastresponse found part interesting me starting <s:envelope rid of extra, not needed data, had extend soapclient, cut required information, , let soapclient rest, valid result.

ended simple this:

class wsdlsoapclient extends soapclient {     public function __dorequest($request, $location, $action, $version, $one_way = 0) {         $response = parent::__dorequest( $request, $location, $action, $version );         if (!$response) {             return $response;         }         // cut part soap result         $matches = array();         preg_match('/<s:envelope.*<\/s:envelope>/s', $response, $matches);         return $matches[0];     } } 

hope helps, cheers


Comments