views:

100

answers:

2

I have a web server which is acting as a SOAP client to communicate with a third party SOAP server. My client is implemented in PHP using php::soapclient.

What is the best way to verify the SOAP server is functioning so I can provide the client browser with the site otherwise if if the SOAP server is down or not responding inform the user that the service is currently not available?

The system essentially provides a mashup of the third party services offered by using SOAP client/server communication to display data to the browser and let the users interact with the third party system.

A: 

You could call the http://server:1234/foo/bar?wsdl and if you do get the WSDL back, fire the actual SOAP request.

If the application is down, you probably won't get the WSDL and if it's only a part of the service that makes it hang, there is not much you can do to detect it beforehand anyway.

Eric Darchis
What is the best way to call some WSDL in this regard? wget comes to mind but I was not sure if there is a better way within php ?
Chris
file_get_contents() assuming you allow urls in fopen. Or check headers with cURL.
timmy
+2  A: 

well... once i worked with a php soap server and a php soap client. I think that when the client calls the service, it passes through the wsdl and if there's a problem during the conection (or even the execution) server side, the response of the client will be a SoapFault object.. id di something like

    $resp = $this->client->__soapCall($serviceName,$serviceParams);
    if (get_class($resp)=="SoapFault"){
         throw new Exception("Webservice error - Message: ".$resp->faultstring);
    }
pleasedontbelong
What type of design would be best to catch these exceptions and notify user of problem along with reporting to site admins for debugging to determine what went wrong?
Chris
i'd say that you could create your own SoapException class that extends from Exception and in the constructor you could save the $resp->faultstring in the DB or send it to the site admins.. and for the users a try-catch should be enough to tell them that there was a problem.. i dont know it that's the "best" but i'd doit like that =)
pleasedontbelong