SOAP

SOAP, originally defined as Simple Object Access Protocol. It relies on Extensible Markup Language (XML) for its message format.SOAP has been adopted as the standard for Web services, and applications from major vendors have developed SOAP APIs for their products, thus making software systems integration easier.

Transport methods

Both SMTP and HTTP are valid application layer protocols used as Transport for SOAP

Message format

POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 299
SOAPAction: “http://www.w3.org/2003/05/soap-envelope”

<?xml version=”1.0″?>
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”>
<soap:Header>
</soap:Header>
<soap:Body>
<m:GetStockPrice xmlns:m=”http://www.example.org/stock”>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

Advantages

  • SOAP is versatile enough to allow for the use of different transport protocols. The standard stacks use HTTP as a transport protocol, but other protocols such as JMS[7] and SMTP[8] are also usable.
  • Since the SOAP model tunnels fine in the HTTP get/response model, it can tunnel easily over existing firewalls and proxies, without modifications to the SOAP protocol, and can use the existing infrastructure.

Disadvantages

  • Because of the verbose XML format, SOAP can be considerably slower than competing middleware technologies such as CORBA.
  • When relying on HTTP as a transport protocol and not using WS-Addressing or an ESB, the roles of the interacting parties are fixed. Only one party (the client) can use the services of the other. Developers must use polling instead of notification in these common cases.

 

To start, First enabling the php SOAP extension  php_soap

When programming some soap server set the “soap.wsdl_cache_enabled” directive in php.ini file to 0:

soap.wsdl_cache_enabled=0

php Soap Client Call

<?php
$client = new SoapClient(“some.wsdl”);
$client = new SoapClient(“some.wsdl”, array(‘soap_version’   => SOAP_1_2));
$client = new SoapClient(“some.wsdl”, array(‘login’          => “some_name”,
‘password’       => “some_password”));

$client = new SoapClient(“some.wsdl”, array(‘proxy_host’     => “localhost”,
‘proxy_port’     => 8080));

$client = new SoapClient(“some.wsdl”, array(‘proxy_host’     => “localhost”,
‘proxy_port’     => 8080,
‘proxy_login’    => “some_name”,
‘proxy_password’ => “some_password”));

$client = new SoapClient(“some.wsdl”, array(‘local_cert’     => “cert_key.pem”));

$client = new SoapClient(null, array(‘location’ => “http://localhost/soap.php”,
‘uri’      => “http://test-uri/”));

$client = new SoapClient(null, array(‘location’ => “http://localhost/soap.php”,
‘uri’      => “http://test-uri/”,
‘style’    => SOAP_DOCUMENT,
‘use’      => SOAP_LITERAL));

$client = new SoapClient(“some.wsdl”,
array(‘compression’ => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));

$server = new SoapClient(“some.wsdl”, array(‘encoding’=>’ISO-8859-1’));

class MyBook {
public $title;
public $author;
}

$server = new SoapClient(“books.wsdl”, array(‘classmap’ => array(‘book’ => “MyBook”)));

?>

 

.