PHP部分调用webservice的方法
<?php
//php.ini中打开下面3个dll
//extension = php_soap.dll //extension = php_curl.dll //extension = php_openssl.dll header("content-type:text/html;charset=utf-8"); $client = new SoapClient(" http://192.168.1.178:808/ChkWelePsw.asmx?WSDL"); //本行测试不可行 $client = new SoapClient(" http://192.168.1.178:808/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,看看是什么类型。 ?>
.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; }