Hi everybody,
I am quite new to NuSoap and I have a little problem I can't figure out: each time my webservice sends a soap_fault, my client doesn't understand it and I get an "HTTP Error: no data present after HTTP headers" error.
Here is a simple version of my code with only the part who doesn't work.
The web service
function getUnmatchedOrdersList($login, $pass) {
//Simply returns a new soap_fault
return new soap_fault('SERVER', '', 'You must be authentificated to use this web-service');
}
|
And the client who simply call the webservice
$client = new soapclient($WSLocation);
$parametres = array('login'=> $_SESSION['userLogin'] ,
'pass' => $_SESSION['userPasswd'] );
$result = $client->call('getUnmatchedOrdersList', $parametres);
$err = $client->getError();
print_r($client->request);
print_r($client->response);
if ($client->fault) {
echo 'SOAP!!!!!!Fault: ';
} else if ($err ) {
//Error
echo 'Error: ' . $err;
} else {
//ok
echo("ok");
}
|
Here is what I got when I execute the client code:
POST /test/webservices/ptws.php HTTP/1.0
Host: localhost
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 573
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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:Body><ns1787:getUnmatchedOrdersList xmlns:ns1787="http://tempuri_org"><login xsi:type="xsd:string">Dav</login><pass xsi:type="xsd:string">pass</pass></ns1787:getUnmatchedOrdersList></SOAP-ENV:Body></SOAP-ENV:Envelope>HTTP/1.1 200 OK
Date: Wed, 22 Nov 2006 22:31:37 GMT
Server: Apache/2.0.59 (Win32) PHP/5.2.0
X-Powered-By: PHP/5.2.0
Content-Length: 0
Connection: close
Content-Type: text/html
Error: HTTP Error: no data present after HTTP headers
|
So it seems that my client take the fault for an error.
As a test, I also tried to change the name of the called function with a false name, and if I do that I effectively receive a fault.
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
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:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Operation 'falseMethod' is not defined in the WSDL for this service</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>SOAP!!!!!!Fault:1<div id="main">
|
Can someone explain me what I did wrong and why my client doesn't receive the faults generated by the server?
Thanks