Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.12 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP SOAP client send XML
  2. require 'inventory_functions.php';
  3.  
  4. ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
  5. $server = new SoapServer("inventory.wsdl");
  6. $server->addFunction("getItemCount");
  7. $server->handle();
  8.        
  9. function getItemCount($upc){
  10.     //in reality, this data would be coming from a database
  11.     $items = array('12345'=>5,'19283'=>100,'23489'=>'234');
  12.     return $items[$upc];
  13. }
  14.        
  15. ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
  16. $client = new SoapClient("http://www.xxx.co.uk/service/inventory.wsdl");
  17. $return = $client->getItemName('12345');
  18. print_r($return);
  19.        
  20. POST /service/mywebservice.php HTTP/1.1
  21. Host: www.xxx.co.uk
  22. Content-Type: text/xml; charset=utf-8
  23. Content-Length: length
  24. SOAPAction: "<your.webservice.namespace>/getItemCount"
  25.  
  26. <?xml version="1.0" encoding="utf-8"?>
  27. <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/">
  28.   <soap:Body>
  29.     <getItemCount xmlns="<your.webservice.namespace>">
  30.       <value>5</value>
  31.     </getItemCount>
  32.   </soap:Body>
  33. </soap:Envelope>