PHP客户端的调用,却实现不了c#客户端

最近写了个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 ";";
}
?>
记得要先下载 nusoaphttp://www.2cto.com/uploadfile/2011/0825/20110825031745407.zip

< ?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 ,可以看到所提供的服务.


C#调用代码


private void button1_Click(object sender, EventArgs e) {
SimpleService svc = new SimpleService();
string s = svc.ProcessSimpleType("400电话 VIP用户");
MessageBox.Show(s);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值