
Untitled
By: a guest on
Apr 26th, 2012 | syntax:
None | size: 1.12 KB | hits: 14 | expires: Never
PHP SOAP client send XML
require 'inventory_functions.php';
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("inventory.wsdl");
$server->addFunction("getItemCount");
$server->handle();
function getItemCount($upc){
//in reality, this data would be coming from a database
$items = array('12345'=>5,'19283'=>100,'23489'=>'234');
return $items[$upc];
}
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$client = new SoapClient("http://www.xxx.co.uk/service/inventory.wsdl");
$return = $client->getItemName('12345');
print_r($return);
POST /service/mywebservice.php HTTP/1.1
Host: www.xxx.co.uk
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "<your.webservice.namespace>/getItemCount"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getItemCount xmlns="<your.webservice.namespace>">
<value>5</value>
</getItemCount>
</soap:Body>
</soap:Envelope>