最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP使用SOAP調(diào)用.net的WebService數(shù)據(jù)

 更新時(shí)間:2013年11月12日 09:50:44   作者:  
需要和一個(gè).net系統(tǒng)進(jìn)行數(shù)據(jù)交換,對(duì)方提供了一個(gè)WebService接口,使用PHP如何調(diào)用這個(gè)數(shù)據(jù)呢,下面就看看使用SOAP調(diào)用的方法吧
這個(gè)與一般的PHP POST或GET傳值再查庫(kù)拿數(shù)據(jù)的思路有點(diǎn)不一樣,需要用到SOAP模塊,處理方法也很簡(jiǎn)單,就是有一些需要注意的事情。
首先確認(rèn)你的PHP.ini開啟了.SOAP,就是 extension=php_soap.dll 這前面的分號(hào)去咯。
代碼很簡(jiǎn)單:
復(fù)制代碼 代碼如下:

<?php
$client = new SoapClient('http://www.aa.net/SearchService.asmx?WSDL');//這個(gè)SOAP地址要換成你自己的
$client->soap_defencoding = 'utf-8'; 
$client->decode_utf8 = false;  
$client->xml_encoding = 'utf-8';
$param = array('param1'=>'01', 'param2'=>'02');
//$param["param1"]="01";
//$param["param2"]="02";
//$result = $client->__soapCall("GetArticle", array( $param ));
$result = $client->__Call("GetArticle", array( $param ));
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);
}
?>

需要注意的一點(diǎn)是,參數(shù)是數(shù)組外再包一層數(shù)組,就是 array( array() )
附SOAP接口的一些參數(shù):
以下是 SOAP 1.2 請(qǐng)求和響應(yīng)示例。所顯示的占位符需替換為實(shí)際值。
復(fù)制代碼 代碼如下:

POST /SearchService.asmx HTTP/1.1
Host: 202.105.183.61
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetTrafficViolationInfo"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetArticle xmlns="http://tempuri.org/">
      <param1>string</param1>
      <param2>string</param2>
    </GetArticle>
  </soap:Body>
</soap:Envelope>

相關(guān)文章

最新評(píng)論

庄浪县| 张家界市| 类乌齐县| 军事| 百色市| 南康市| 霍城县| 闸北区| 亚东县| 泰顺县| 文昌市| 九龙坡区| 乳源| 榆树市| 昌乐县| 理塘县| 腾冲县| 湖南省| 惠安县| 三台县| 赣州市| 泰顺县| 泗阳县| 长海县| 神木县| 齐河县| 资溪县| 基隆市| 马山县| 随州市| 左贡县| 宜川县| 深圳市| 庄河市| 随州市| 盐池县| 虹口区| 佛冈县| 韩城市| 泗洪县| 赣州市|