php soap服务器如何侦听soap客户端c程序?
我的soap客户端工作正常,我正在寻找一种方法,将数据从soap客户端(用c编写)发送到用php编写的soap服务器。 我所知道的php中的基本初始化如下php soap服务器如何侦听soap客户端c程序?,php,Php,我的soap客户端工作正常,我正在寻找一种方法,将数据从soap客户端(用c编写)发送到用php编写的soap服务器。 我所知道的php中的基本初始化如下 $soapServer= new SoapServer("test.wsdl"); $soapServer->setClass('myClass'); $data = file_get_contents('php://input'); $soapServer->handle(); 但究竟如何让php“监听”并从soap客户端
$soapServer= new SoapServer("test.wsdl");
$soapServer->setClass('myClass');
$data = file_get_contents('php://input');
$soapServer->handle();
但究竟如何让php“监听”并从soap客户端接收数据呢?
有什么想法吗 如果生成SOAP服务器,则必须定义函数: 你做一个函数
<?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];
}
?>
现在将该函数添加到SOAP服务中
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("inventory.wsdl");
$server->addFunction("getItemCount");
$server->handle();
?>
函数getItemCount被添加到SOAP服务中
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("inventory.wsdl");
$server->addFunction("getItemCount");
$server->handle();
?>
要使用客户端对此进行测试,请执行以下操作:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$client = new SoapClient("http://[path to the service]/inventory.wsdl");
$return = $client->getItemCount('12345');
print_r($return);
?>
有关更多信息和详细信息