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