PHP samples calling web servicehttp://msdn.microsoft.com/en-us/library/cc540209.aspxyou need to enable soap and open ssl extension.
If your service is a .NET doc/lit, which means the input message has a single part named 'parameters' that is a structure that wraps the parameters. Your call should look like this: <?php $params = array('param_name_1'=>$val_1,'param_name_2'=>$val_2); $client->call('MethodName', array('parameters' => $params)); ?>你看看下面这个例子! <?php header('Content-type:text/html;charset=utf-8'); require_once 'city.php'; //这里为城市与城市编码的缓存文件,也是从webxml上获取的。 if($_POST['submit']==='OK') { $client = new SoapClient('http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'); $code = $_POST['city']; $para = array('theCityName'=>$code); //getWeatherbyCityName只需要一个参数,参数名theCityName //每调用一个方法,都会有一个对应的返回结果,结果名称为:方法名+Result,如下面的getWeatherbyCityNameResult,该返回结果为object $res = $client->__Call('getWeatherbyCityName',array('paramters'=>$para))->getWeatherbyCityNameResult->string; echo "<pre>"; echo "城市:".$res[1]; echo "<br/>气温:".$res[5]; echo "<br/>天气:".$res[6]; echo "<br/>风力:".$res[7]; echo "</pre>"; } ?>
如果有wsdl文件会更方便~
Your call should look like this:
<?php
$params = array('param_name_1'=>$val_1,'param_name_2'=>$val_2);
$client->call('MethodName', array('parameters' => $params));
?>你看看下面这个例子!
<?php
header('Content-type:text/html;charset=utf-8');
require_once 'city.php'; //这里为城市与城市编码的缓存文件,也是从webxml上获取的。
if($_POST['submit']==='OK')
{
$client = new SoapClient('http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl');
$code = $_POST['city'];
$para = array('theCityName'=>$code); //getWeatherbyCityName只需要一个参数,参数名theCityName
//每调用一个方法,都会有一个对应的返回结果,结果名称为:方法名+Result,如下面的getWeatherbyCityNameResult,该返回结果为object
$res = $client->__Call('getWeatherbyCityName',array('paramters'=>$para))->getWeatherbyCityNameResult->string;
echo "<pre>";
echo "城市:".$res[1];
echo "<br/>气温:".$res[5];
echo "<br/>天气:".$res[6];
echo "<br/>风力:".$res[7];
echo "</pre>";
}
?>