Extending class SoapServer (PHP5) for debugging

In one of our large projects the application platform we developed provides a SOAP Service to several external entities (mainly .NET, Java and VisualBasic based, both web application and desktop software). These entities are spread across Europe and involve both internal consumers (departments from our customer) and external consumers (other solution providers that want to dock their solution onto the platform and interact with it remotely through the SOAP interface).

The SOAP Service, a SOAP server based on PHP5’s ext/soap, provided only small debugging capabilities, mainly for some methods during the pre-testing phase that error_log‚ed to a logfile on the server. This was a sufficient short-term solution up-to-date, for eliminating outstanding bugs during development and testing with the SOAP consumers.

However, for long-term reasons (it’s a large multi-year project) and to provide more comfort for our customer (internal monitoring) and the communication from us (the development team) to the external entities (internal/external consumers of the webservice), we decided to improve the debugging capabilities of the SOAP service. It should log the time of the SOAP request (to pinpoint bottlenecks and see if bottlenecks come from routing reasons or from the platform itself), the issued SOAP commands, the full XML that was received and sent and several other information.

For those of you who don’t know, there’s a pretty easy way to achieve this (thanks to Marco for implementing the solution): you can easily extend PHP5’s SOAPServer class and hook into the constructor and handle() method to implement your debugging code. Unfortunately at the moment (does anyone know if there’s perhaps some undocumented function for this? Or does SCA support any of these capabilities out of the box?) we have to preg the submitted SOAP XML to get all information out of it. Below you can find some sample code.

This small example code utilizes some helper functions like a Timer class, XML string beautifier and the like and enables the SOAP Server itself to save the data into the database later on. The SOAP server code was changed from:


Et voilà. From there it’s pretty easy to put on top a small paging application that lets you flip
through all the saved datasets from the DB. With this small effort you get a pretty decent
debugging possibility for SOAP calls to your SOAP service.

Für neue Blogupdates anmelden:

5 Gedanken zu “Extending class SoapServer (PHP5) for debugging

  1. Pingback: SoapServer maps functions incorectly when the wsdl messages have the same part name

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *