- Some WSDL file.
- Some endpoint that either coughs up the wsdl or let’s the SOAP server handle a request.
- An object that does the SOAP handling (use SOAPServer::setObject)
- A SoapClient to see what happens when the SOAP server is called
- A I love to use unit tests for spike solutions: a unit test
Goal: get a little SOAP service up and running and see what we can use SOAP headers for.
Point is: if the SOAP client send a SOAP header with a fixed name, you need a function with the SOAP header’s name in the class you use as SOAP server object.
If the header processing function exists and the header is sent, SoapServer::handle()
calls first the header processing function and then the requested SOAP function.
This means you can user the header e.g. for user authentication or setting some locale id etc. without having to change the wsdl. Good for backward compatibility.
Here’s the code:
Note: I did this example here with PHP 5.3.5-1ubuntu7.7 with Suhosin-Patch (cli) (built: Feb 11 2012 06:22:51).