From PHP version 5.0.4, PHP has a SOAP extension. Using this SOAP Extension supports SOAP client applications with a class called SoapClient, which offers the following main functions:
The SoapClient->__construct() constructor creates SoapClient objects in WSDL or non-WSDL mode. This function also has some options like the location and uri options, where location is the URL to request and uri is the target namespace of the SOAP service. SoapClient->__getFunctions() allows you to get a list of functions supported by the target node. This function is only valid in WSDL mode. After getting the supported functions, SoapClient->__soapCall() allows you to make an RPC function call on the target SOAP node. Our above client implementation can also be developed using the PHP SOAP extension as shown below. <?php //Call the add function of SOAP server ?> If we are using WSDL then we can simply call the remote function as local function. The above example will generate same output as below. <?php //Call the add function of SOAP server (possible only in WSDL Mode) ?> The PHP SOAP extension is very useful for creating SOAP headers with security credentials. Usernames and passwords can be securely encrypted and then added into SOAP headers using the SOAP extension of PHP. In this article I tried to focus on some different implementations of SOAP using PHP. Both PEAR::SOAP and NuSOAP are easy to install and use. But I personally like PHP5's SOAP extension, because it has more features than the other two. But if you are using a PHP version earlier than 5.0.4, you have to use these libraries.
blog comments powered by Disqus |