SOAP Server in Codeigniter |
[eluser]SkiOne[/eluser]
I hear how doing SOAP in PHP is so hard and I also hear the doing SOAP in codeigniter is impossible. I am here to tell you that is not true. The problem is that it is not well documented. In addition PHP does not support auto WSDL generation, if you add ?wsdl to your SOAP endpoint you will get a message like "auto wsdl generation is not supported" NICE! So what is SOAP, its many things but for the purposes of this conversation its helpful to think of SOAP as a way to expose methods of a class via a web service and have those methods be self defining. In order to accomplish this you need to document your class, instantiate a SOAP server (using PHP's soap class) and then add a 3rd party library to generate the WSDL. I'll start with the last one first. This goes into the library folder: http://pastebin.com/qmzZa3wd //sorry for the pastebin link Next we need a method that will invoke and call this code: Code: public function wsdl() So this is a hack, normally in SOAP you add ?wsdl to your endpoint to get the wsdl here you would do /controller/wsdl. I am sure you could write some code to mimic the normal behavior but so far this has worked for me. You also need to properly comment your methods for this to work (example later). Next you will need to instantiate your soap server: Code: public function index() { In the setClass method you specify the name of the controller that has your SOAP methods for me I went with the ever original 'api' name And thats pretty much it, here is an example of a method that is properly documented: Code: /** Also if you want to do authentication in your header it would look something like this: Code: /** Then you could make a function to check auth status: Code: protected function checkAuth()
[eluser]AgustÃn Villalba[/eluser]
You can also find information about SOAP servers in Codeigniter here: http://phpsblog.agustinvillalba.com/crea...odeigniter Cheers,
[eluser]PravinS[/eluser]
You can refer this script Quote:http://www.php-guru.in/2013/soap-server-...p-library/ |
Welcome Guest, Not a member yet? Register Sign In |