In this tutorial, we will look at how to create a complete PHP SOAP server in WSDL mode. You can take a look at How we generated the WSDL file for this tutorial.
I assumed that you have already enabled SOAP in your PHP configuration.
From the code below, we first create a simple php class, exampleClass with two functions; boom() and getDate(). We also create corresponding classes, boomResponse and getDateResponse for their return type. From the WSDL file, you will notice that the response type for both boom and getDate is defined as complexType. A complexType is represented as Struct in SOAP, which we can represent as a class in php. Also, note that the names of the response classes must match exactly what you have in your WSDL file.
After creating the appropriate classes for our soap server, we instantiate the PHP SoapServer object in WSDL mode by passing the WSDL file as a parameter. We call the setClass() method on the object to set the class for this soap server and finally call the handle() method to handle soap request.
Kindly leave a comment if you find this tutorial useful.