PHP SOAP服务器端 C#客户端

简介:这是PHP SOAP服务器端 C#客户端的详细页面,介绍了和php,php PHP SOAP服务器端 C#客户端有关的知识、技巧、经验,和一些php源码等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=347711' scrolling='no'>
最近写了个PHP的SOAP服务器 端,实现了PHP客户端的调用,却实现不了c#客户端的调用,看完了手册找了N久也没实现其访问 ,最后试用了一下NuSOAP
SF.net上的一个开源 项目,效果 很好,很Eacy就实现了所需的功能
c#的web 服务 (服务器端)是非常容易实现的,C#客户端调用也很方便
PHP的web服务器端 一般要生成一个.wsdl的文件 ,.wsdl是一个Xml文件描述提供的服务
下面来看看我的第一个PHP web服务
<?php
/**
* ProcessSimpleType method
* @param string $who name of the person we'll say hello to
* @return string $helloText the hello string
*/
function ProcessSimpleType($who) {
return "Hello $who,欢迎访问 http://www.my400800.cn ";
}
?>
记得要先下载 nusoap
<?php
require_once("lib/nusoap/nusoap.php");
$namespace = "http://www.my400800.cn";
// create a new soap server
$server = new soap_server();
// configure our WSDL
$server->configureWSDL("SimpleService");
// set our namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register our WebMethod
$server->register(
// method name:
'ProcessSimpleType',
// parameter list:
array('name'=>'xsd:string'),
// return value(s):
array('return'=>'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style. rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'A simple Hello World web method');

// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>
写完之后就可以使用了
打开.net,添加引用


下一步点击wsdl ,可以看到所提供的服务,如下图




php PHP SOAP服务器端 C#客户端


php PHP SOAP服务器端 C#客户端



C#调用代码
private void button1_Click(object sender, EventArgs e) {
SimpleService svc = new SimpleService();
string s = svc.ProcessSimpleType("400电话 VIP用户");
MessageBox.Show(s);
}
结果

爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

http://biancheng.dnbcw.info/php/347711.html pageNo:4

posted on 2011-11-08 07:51  圣者  阅读(345)  评论(0编辑  收藏  举报

导航