繁体   English   中英

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

[英]how can a php soap server listen to a soap client c program?

我的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
$client = new SoapClient("http://[path to the service]/inventory.wsdl");
$return = $client->getItemCount('12345');
print_r($return);
?>

有关更多信息和详细信息,请访问http://jimmyzimmerman.com/blog/2007/02/soap-server-with-php5-part3-the-glue-code.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM