In a previous few posts, I posted examples for the NuSOAP server. Now it is time for the intrinsic PHP SOAP web service. This will be a quick post for the server and client, as they are easy to do. The hard part will be the WSDL document. With NuSOAP, it created a WSDL for you, but with PHP SOAP, you must do the WSDL yourself. Be sure to read up on the documentation at PHP.net.
So first off, we need to create a few ideas on what we will return. This will be a simple example with data returned. So for the data set, we will return an array of colors, and an array of named pairs for boys/names and girls/names. Two simple methods to the service, and we need to build the client as well.
So this post will only be the set up of those, and maybe next week I will post the actual server and client code. So for now, here are the data arrays we are going to work with:
$colors = array( 'blue', 'green', 'black' 'white', 'yellow' 'red', 'beige' ); $names = array( 'boys' => array( 'stephen', 'dave', 'ryan', 'brian', 'chris', 'tom', ), 'girls' => array( 'elise', 'sheri', 'kim', 'marci', 'megan', ) );
And we will need the WSDL file in place. So the basic layout for this webservice server will act like this:
1. All calls to the colors function will not take any type of parameters, it will be:
$webservice->__soapCall('getColors')
2. Calls to the names function can be one of three options: both, girls, boys:
$webservice->__soapCall('getNames', array('boys'))
3. Both functions will return some type of message header and array of returned data.
4. The data is set up above, and the structure will be the same.
Now knowing this, if we get the WSDL set up and working, then the service will work. So next week, I will show the WSDL, the Server and the Client.