Web Service using SOAP

Simple Object Access Protocol(SOAP) provides communicate between applications is over HTTP protocol. The communication of request and response by the xml data.

prerequisite PHP Extension are

Web services approach has 2 component
1. Service Provider (Service provider)
2. Service requester (Service Consumer)

The SOAP communication is done by pure xml structure as follows

The simple authentication are illustrated as follows
The Full Source Code

Service consumer(Soap Client):
It just invoke the web service implemented by the service provider.
It has soap client where it can connection can be made and in the do request method ,we can mention th endpoint url and request url.

$request getSoapAuthenticateRequestXML('vivekanandan','newpwd123');
$client = new SoapClient(null,array(location=>$url,uri=>$url,'exceptions'=>FALSE,'trace'=>true));
$xmlstr $client->__doRequest($request,$url,"",1);

Request XML:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope  xmlns:SOAP-ENV=""   xmlns:xsi="" >


Service Provider(Soap Server):
It implements the web service. Web Services Description Language(Wsdl) file is a xml document which describe Web services. Each and every SOAP request and SOAP response
Has wel defined in the wsdl file .
It created soapserver with the wsdl so that all the soap client request will be checked with the wsdl and corrensponding mentod will be called.

Depends upon the request xml the wsdl will be checked In the top to bottom that finally from service tag the corresponding operation or function will be called.

Soap Request :
Message -> portType -> binding -> service
Message -> complexType -> UserCredentialRequest

class UserAuthentication {
    public function 
$reqData->Username=='vivekanandan' &&  $reqData->Password=='123456'){
$vResponseText ='Valid';
     }else {
$vResponseText 'Invalid';
$vResponseText "<UserCredentialResponse><Status>".$vResponseText."</Status></UserCredentialResponse>";
$outData = new SoapVar($vResponseTextXSD_ANYXML"Response"nullnull);    

$server = new SoapServer("UserAuthentication.wsdl");

After the operation or function is executed , then the soap framework will lookup for the response to the soap client
Soap Response:
Message -> portType -> binding -> service
Message -> complexType -> UserCredentialResponse

SOAP Response XML

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:xsi="">