最近写了个php的soap服务器 端,实现了php客户端的调用,却实现不了客户端的调用,看完了手册找了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, 欢迎访问“;“;
}
?>
记得要先下载 nusoap
<?php
require_once(“lib/nusoap/nusoap.php”);
$namespace = “”;
// create a new soap rver
$rver = new soap_rver();
// configure our wsdl
$rver->configurewsdl(“simplervice”);
// t our namespace
$rver->wsdl->schematargetnamespace = $namespace;
// register our webmethod
$rver->re光盘行动口号gister(
// method name:
‘processsimpletype’,
// parameter list:
array(‘name’=>’x边塞的古诗sd:string’),
// return value(s):
array(‘return’=>’xsd:string’),
// namespace:
$namespace,
// soapaction: (u default)
fal,
// style. rpc or document
‘rpc’,
// u: encoded or literal
‘encoded’,
// description: documentation for the method
‘朝代顺口溜a simple hello world web method’);
// get our posted data if the rvice is being consumed
// otherwi leave this data blank.
$post_data = ist($globals[‘http_raw_post_data’]) ? $globals[‘http_raw_post_data’] : ”;
// pass our posted data (or nothing) to the soap rvice
$rver->rvice($post_data);
exit();
?>
写完之后就可以使用了
打开.net,添加引用
下一步点击wsdl ,可以看到所提供的服务,如下图
c#调用代码
private void button1_click(object nder, eventargs e) {
simplervice s = new simplervice();
string s = svc.processsimpletype(“400电话 vip用户”);
messagebox.show(s);
}
结果
本文发布于:2023-04-07 06:16:32,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/76b82886e675ec4389be09f7064e9cf2.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:PHP SOAP服务器端C#客户端.doc
本文 PDF 下载地址:PHP SOAP服务器端C#客户端.pdf
留言与评论(共有 0 条评论) |