Meanings of common SOAP faults and Error Messages in WSF/PHP

Friday, February 1, 2008

If you have work with web services for some time, you should be familiar with different SOAP faults. There are mainly two kind of SOAP Faults that you encounter in web services.

1. SOAP faults originated from the web service engine. - On which I will be talking today..
2. SOAP faults originated from the service business logic. (Custom faults)

In WSF/PHP, you will find separate PHP class represent soap faults called WSFault. It has two mandatory fields, one is 'code' which most commonly has the value "sender", and the other is 'reason'. Here the reason will give you a good understanding of the problem mostly in your request message.

You can always echo the fault reason using a try, catch block. (Taken from WSF/PHP echo sample)

try {
$res = $wsclient->request($req);
catch (Exception $e) {

if ($e instanceof WSFault) {
printf("Soap Fault: %s\n", $e->Reason);

else {
printf("Message = %s\n",$e->getMessage());


Sometime the reason itself doesn't descriptive, this is mostly because of the same reason can be caused by different faults in the message and soap engine just cannot determine which one is the most close one.

In addition to soap faults, the WSF/PHP tells you some other problem in your request by throwing PHP native exceptions. You can see a description of the error through getMessage method in the Exception class. Please note how we are catching the both form of exception in the try catch block.

Here is a little list of messages you may get from above listed code and what their actual meanings,

1. Message = request payload should not be null

This is not a SOAP fault, just an error occurred by the soap engine. This can be caused by
i. As it says the $req in the above code is NULL.
ii. $req contains malformed XML.
i.e. something like
$req = "<hello></hello>"; /* note that '>' is missing in first hello */

2. Message = Error , NO Response Received

This too is not a SOAP fault, but very common message. Here is some of the possible reasons that can cause this message.

i. As it means, the Server is not sending anything to the client in reply. This it self can be due to several reasons like
*. The server is not on.
*. The server have crashed while processing the request. :(
*. The server takes long time. So the timeout value expires..
ii. Next server send something in reply, but it is not a soap message. That is you have most probably send a soap request to a non-soap server.

iii. The service endpoint is invalid if the endpoint is WSF/PHP service. In normally case this should return a soap fault saying service not found. but since WSF/PHP consider a script running on the PHP as a service, and PHP doesn't always invoke WSF/PHP code unless it has use WSF/PHP objects, this just return a 401 Not found. Surely this is not a soap message. so the client will be displayed the error 'No Response Received'

3. Soap Fault: Operation Not Found

The SOAP engine fails to identify the service operation. Here I assume the soap service also written in WSF/PHP

i. if soap action or wsa addressing is not used, (that is "action" option in WSClient or WSMessage constructor),
Name of the first Element of the request ( That becomes the operation name), is not matched with the expected operation of the service which can be specified in the "operation" array of the WSService object.
E.g. (The correct code)
If request message is

the service should be created with
$service = new WSService("operation" => array("request" =>"requestHandlerFunction"));

if these two entities has different values, this soap fault will be sent.

ii. if the action (either the soap action or wsa action) is specified,
the client side and the server side have different value for action + the early point satisfied.
E.g. (The Correct code)

$client = new WSClient(array("to" => "http://myhost/samples/request_service.php",
"action" => "myrequest"));
And the server side
$service = new WSService("operation" => array("request" =>"requestHandlerFunction"), //the operation to function map
"actions" => array("myrequest" => "request")); //here is the action to operation map

Note that if these action are different but the service operation name is same as the request node name, still the operation will be successfully dispatched.

These are the common messages that I have met with. In addition to that if you have used security features, you may have seen WSFault reasons relating to security which are mostly self-descriptive.

Please comment here, if you met with any other regular error, fault messages.

1 comment:

Jackline said...

Hi Nice Blog .If your time is less valuable, then it is probably less worthwhile to employee time attendance.