PHP SOAP 客户端发送 XML
我正在尝试使用 PHP 创建一个 Web 服务。以下是我的代码 -
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?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否理解你的问题。您想知道应该为 Web 服务提供什么 XML 输入才能发送值“5”?
为了做到这一点,您应该首先分析生成的 wsdl 文件,然后,根据您为客户端选择的编程语言,您可以生成一个客户端存根来与 Web 服务本身交互。
或者,您可以直接向 Web 服务发出带有 XML 的 HTTP POST(应如下所示):
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):