【发布时间】:2012-02-24 12:48:54
【问题描述】:
我正在尝试使用 PHP 创建 Web 服务。以下是我的代码-
网络服务器 -
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];
}
我的客户测试 -
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);
当我运行它时,一切正常。数字“5”将在我的浏览器中输出。我真正需要的是一些关于如何通过 XML 将数据发送到 SOAP 服务器的帮助,我会将这些数据添加到 MySQL。
如何通过客户端测试发送 XML?
谢谢
【问题讨论】:
标签: php xml web-services soap