CHAPTER 20 WEB SERVICES addFunction() void SoapServer->addFunction (Web site)
Friday, December 21st, 2007CHAPTER 20 WEB SERVICES addFunction() void SoapServer->addFunction (mixed functions) You can make a function available to clients by exporting it using the addFunction() method. In the WSDL file, there is only one function to implement, getQuote(). It takes $boxer as a lone parameter, and returns a string. Let s create this function and expose it to connecting clients: addFunction(”getQuote”); ?> When two or more functions are defined in the WSDL file, you can choose which ones are to be exported by passing them in as an array, like so: $soapserver->addFunction(array(”getQuote”,”someOtherFunction”); Alternatively, if you would like to export all functions defined in the scope of the SOAP server, you can pass in the constant, SOAP_FUNCTIONS_ALL, like so: $soapserver->addFunction(array(SOAP_FUNCTIONS_ALL); It s important to understand that exporting the functions is not all that you need to do to produce a valid SOAP server. You also need to properly process incoming SOAP requests, a task handled for you via the method handle(). This method is introduced next. handle() void SoapServer->handle ([string soap_request]) Incoming SOAP requests are received by way of either the input parameter soap_request or the PHP global $HTTP_RAW_POST_DATA. Either way, the method handle() will automatically direct the request to the SOAP server for you. It s the last method executed in the server code. You call it like this:
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.