I am trying to create a web service with PHP. The following is my code –
Web Server –
require 'inventory_functions.php';
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("inventory.wsdl");
$server->addFunction("getItemCount");
$server->handle();
Inventory_functions.php –
function getItemCount($upc){
//in reality, this data would be coming from a database
$items = array('12345'=>5,'19283'=>100,'23489'=>'234');
return $items[$upc];
}
My Client Test –
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);
When I run this everythign is OK. the number “5” will output in my browser. WhatI really need is some help in how to go about sending data via XML to the SOAP server, from their I will add this data to MySQL.
How would I send the XML vie the client test?
Thanks
I’m not sure I understand your question. You want to know what XML input you should give your web-service in order to send for instance the value “5”?
In order to do that you should first analyse the wsdl file that is generated, then, depending on your programming language of choice for the client, you may generate a client Stub to interact with the Web-Service itself.
Alternatively, you may issue an HTTP POST with the XML directly to the web-service (should look something like this):