NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Problem with soap_faults


Joined: 16 Nov 2006
Posts: 3
Reply with quote
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.

Code:

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
Code:

   $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:
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. Sad

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.
Code:

<?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 &apos;falseMethod&apos; 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
View user's profileFind all posts by DavSend private message


Joined: 16 Nov 2006
Posts: 3
Reply with quote
Good morning everybody,

I searched deeper and I found something really werd.
But first here is the code is use to make the tests:

Code:

The webservice
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require('nusoap/lib/nusoap.php');

$server = new soap_server();
$server->register('getUnmatchedOrdersList');
 
function getUnmatchedOrdersList($login, $pass) {
   return new soap_fault('SERVER','','Test fault');
}
 
/** Use the request to (try to) invoke the service */
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
 
 ?>


Code:

The simple client
<?php
require_once('includes/nusoap/lib/nusoap.php');
$client = new soapclient("http://localhost/myproject/webservices/ptws_orders.php");
$parametres = array('login'=> 'Dav', 'pass' => 'pass' );               
$result = $client->call('getUnmatchedOrdersList',$parametres);

//Check for error
$err = $client->getError();                                              

echo ($client->request);
echo ($client->response);

if ( $client->fault) {
   echo("SOAP fault: ".$client->faultstring);
} else if ($err) {
     echo ('Error: ' . $err);
}  else {
   echo ("OK");
}

?>


Now if I run the previous code on my first development server which is running on Apache 2.0.59 with PHP 5.2.0 I have the following result:
"Error: HTTP Error: no data present after HTTP headers" which is not the excepted one.

BUT, if I run it on my second server which is running on Apache 1.3.33 with PHP 4.3.10 I have the following result:
"SOAP fault: Test fault" which is the good one. Shocked

Has someone ever had this kind of problem? I don't understand where do the problem comes from, can it be the configuration of the server?

Thanks
View user's profileFind all posts by DavSend private message


Joined: 16 Nov 2006
Posts: 3
Reply with quote
Hello again,

I put back the error reporting on my web-service and I think I found the reason of the error :

Code:

<b>Catchable fatal error</b>:  Object of class soap_fault could not be converted to string in <b>F:\Projet Industriel\site\webservices\nusoap\lib\nusoap.php</b> on line <b>3613</b><br>
SOAP Error: Response not of type text/xml


Can someone tell me if it's a problem of the library or if I did something wrong?
Are there any workarounds?

Any help is welcome.
Thanks
View user's profileFind all posts by DavSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Quote:
SOAP Error: Response not of type text/xml

it means that your server did not respond with a soap (xml) as it would expected.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Problem with soap_faults
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic