PHP 调用asp.net Web Services服务问题总结
Catchable fatal error: Object of class stdClass could not be converted to string in ...
PHP是弱类型语言,转换非常不方便。
<?php
//soap 客户端
$client=new SoapClient('http://localhost:1278/WebSite1/WebService.asmx?WSDL');
$hello = $client->HelloWorld();
echo $hello;//不可以直接输出会有以下错误提示,但在Java下却正常。
//必须采用以下循环输出即可
foreach ($hello as $h)
{
echo $h;
}
?>
调用多个参数
$sum = $client->Sun(array('a'=>5,'b'=>85));
foreach ($sum as $s) {
echo $s;
}
C#:
[WebMethod]
public String Sun(Int32 a ,Int32 b)
{
return a + b+"";
}
//另一种调用方法
$sum = $client->__call('Sun',array('parameters'=>array('a'=>4,'b'=>4)));
foreach ($sum as $s) {
echo $s;
}
服务器端编写:
访问: http://localhost/index.php?wsdl