简体   繁体   English

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

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

My soap client is working fine and I'm looking for a way send data from soap client (written in c) to soap server written in php. 我的soap客户端工作正常,我正在寻找一种方法将数据从soap客户端(用c编写)发送到用php编写的soap服务器。 What I know the basic initiate in php like the following 我所知道的PHP基本启动器如下所示

$soapServer= new SoapServer("test.wsdl"); 
$soapServer->setClass('myClass');
$data = file_get_contents('php://input');
$soapServer->handle(); 

But exactly how can I let php "listen" and receive data from soap client? 但是究竟如何让php“监听”并从soap客户端接收数据? Any idea? 任何想法?

If you generate a SOAP server, you have to define your functions: 如果生成SOAP服务器,则必须定义函数:

You make a function 你做一个功能

<?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];
}
?>

Now add that function to your SOAP service 现在将该功能添加到您的SOAP服务中

<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("inventory.wsdl");
$server->addFunction("getItemCount");
$server->handle();
?>

That function getItemCount is added to your SOAP service 该功能getItemCount被添加到您的SOAP服务中

To test this with a client: 要与客户进行测试:

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

For more information and details http://jimmyzimmerman.com/blog/2007/02/soap-server-with-php5-part3-the-glue-code.html 有关更多信息和详细信息,请访问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