最近遇到一个项目,需要使用C# 调用PHP编写的Webservices 发送短信。如下是实现方案,仅供参考
//server端 serverSoap.php $soap = new SoapServer(null,array(‘uri‘=>"http://192.168.1.123/")); $soap->addFunction(‘Add_func‘); //Register the function $soap->addFunction(SOAP_FUNCTIONS_ALL); $soap->handle(); function Add_func($i, $j){ $res = $i + $j; return $res; }
//client端 clientSoap.php try { $client = new SoapClient(null, array(‘location‘ =>"http://192.168.1.123/test/serverSoap.php",‘uri‘ => "http://127.0.0.1/") ); echo $client->Add_func(100,99); } catch (SoapFault $fault){ echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring; }
wsdl /language:c# /n:wsdlLib /out:D:/ServiceProxy.cs http://192.168.1.123/test/serverSoap.php?wsdl
c# 调用 PHP 编写的Web Services,布布扣,bubuko.com
原文:http://www.cnblogs.com/sam-peng/p/3596052.html