Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php soap服务器如何侦听soap客户端c程序?_Php - Fatal编程技术网

php soap服务器如何侦听soap客户端c程序?

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客户端

我的soap客户端工作正常,我正在寻找一种方法,将数据从soap客户端(用c编写)发送到用php编写的soap服务器。 我所知道的php中的基本初始化如下

$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);
?>

有关更多信息和详细信息