PHP使用SOAP调用.net的WebService数据
分类:PHP作者:编程之家
这个与一般的PHP POST或GET传值再查库拿数据的思路有点不一样,需要用到SOAP模块,处理方法也很简单,就是有一些需要注意的事情。
首先确认你的PHP.ini开启了.soAP,就是 extension=PHP_soap.dll 这前面的分号去咯。
代码很简单:
<div class="codetitle"><a style="CURSOR: pointer" data="6208" class="copybut" id="copybut6208" onclick="doCopy('code6208')"> 代码如下:
<div class="codebody" id="code6208">
<?
PHP$client = new SoapClient('
http://www.aa.net/SearchService.asmx?WSDL');//这个SOAP地址要换成你自己的$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'utf-8';
$p
aram = array('p
aram1'=>'01','p
aram2'=>'02');
//$p
aram["p
aram1"]="01";
//$p
aram["p
aram2"]="02";
//$result = $client->__soapCall("GetArticle",array( $p
aram ));
$result = $client->__Call("GetArticle",array( $p
aram ));
if (is_soap_fault($result))
{
trigger_error("SOAP Fault: (faultcode: {$result->faultcode},faultstring: {$result->faultstring})",E_USER_ERROR);
}
else
{
$data = $result->GetArticleResult;//这里返回的是类,必须使用->得到元素的值
print_r($data);
}
?>