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.
This comment has been removed by a blog administrator.
ReplyDeleteThis is clear and easy example I have ever found in entire google search. You are awesome and keep it up good works!
ReplyDeleteHow did you get to see the example page
DeleteThanks @Mathaalbhai
ReplyDeleteGood way to learn php web service soap server for starters!!!
ReplyDeleteIts dropping me this:
ReplyDeletestring(182) "
Parse error: syntax error, unexpected ' ' (T_STRING), expecting function (T_FUNCTION) in C:\xampp\htdocs\example\exampleClassServer.php on line 5
"
when i call it with your tutorial
Send SOAP request XML via PHP cURL
Any ideas?
@Robert, there seems to be extra unicode characters (unicode) in your file. These characters are introduced during copy and paste which caused the php parser to throw the above error. Simply copy and paste the codes sample in notepad first and then copy from notepad to your exampleClassServer.php file.
DeleteHello, I think your site might be having browser
ReplyDeletecompatibility issues. When I look at your blog site in Ie,
it looks fine but when opening in Internet Explorer, it has some overlapping.
I just wanted to give you a quick heads up!
Other then that, awesome blog!
Ahaa, its good dialogue concerning this piece of writing at
ReplyDeletethis place at this blog, I have read all that, so now me also commenting here.