源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php实现通过soap调用.Net的WebService asmx文件

  • 时间:2022-08-10 14:14 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php实现通过soap调用.Net的WebService asmx文件
本文实例讲述了php实现通过soap调用.Net的WebService asmx文件。分享给大家供大家参考,具体如下: 最近,帮一个同行测试用.net写的WebService接口,C#调用通过,现在需要测试一下php版本对它的调用,经过各种探索,相关的PHP调用webservice的过程如下: [b]1.打开php相关扩展:[/b] 找到配置文件php.ini 文件, 打开以下扩展
extension = php_soap.dll
extension = php_curl.dll
extension = php_openssl.dll

[b]2.php代码如下:[/b]
<?php
header("content-type:text/html;charset=utf-8");
$client = new SoapClient(" http://192.168.3.178:8080/ChkWelePsw.asmx?WSDL");
//本行测试不可行 $client = new SoapClient(" http://192.168.3.178:8080/chkwelepsw.asmx?WSDL/ChkWele?username=test3&psw=123");
//参数这样传递 先包装一下
$param = array('username'=>'test3','psw'=>'123');
//调用必须用__soapCall
$p = $client->__soapCall('ChkWele',array('parameters' => $param));
print_r($p->ChkWeleResult); //这里先输出一下变量$p,看看是什么类型。
?>

注意,在php调用某个方法后,其soap对象,就会自动产生一个Result方法,以方便显示调用结果,如上面的 被调用端的WebService的 “ChkWele”方法 , 调用端就有相应的“ChkWeleResult”方法。 .NET部分 webservice要注意的地方
/*
 *  <system.web>在这个节点中加入如下内容
  <webServices>
   <protocols>
    <add name="HttpSoap"/>
    <add name="HttpPost"/>
    <add name="HttpGet"/>
    <add name="Documentation"/>
   </protocols>
  </webServices>
 */
[WebMethod(Description = "This......", EnableSession = false)]
public string ChkWele(string username, string psw)
{
  string ret = "";
  return ret;
}

更多关于PHP相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/234.htm]PHP针对XML文件操作技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/623.htm]PHP数组(Array)操作技巧大全[/url]》、《[url=http://www.1sucai.cn/Special/47.htm]php字符串(string)用法总结[/url]》、《[url=http://www.1sucai.cn/Special/196.htm]PHP错误与异常处理方法总结[/url]》、《[url=http://www.1sucai.cn/Special/348.htm]PHP基本语法入门教程[/url]》、《[url=http://www.1sucai.cn/Special/43.htm]php面向对象程序设计入门教程[/url]》、《[url=http://www.1sucai.cn/Special/84.htm]php+mysql数据库操作入门教程[/url]》及《[url=http://www.1sucai.cn/Special/231.htm]php常见数据库操作技巧汇总[/url]》 希望本文所述对大家PHP程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部