色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP使用SOAP調用.net的WebService數據

這個與一般的php POST或GET傳值再查庫拿數據的思路有點不一樣,需要用到SOAP模塊,處理方法也很簡單,就是有一些需要注意的事情。
首先確認你的php.ini開啟了.SOAP,就是 extension=php_soap.dll 這前面的分號去咯。
代碼很簡單:
復制代碼 代碼如下:
<?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';
$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);
}
?>

需要注意的一點是,參數是數組外再包一層數組,就是 array( array() )
附SOAP接口的一些參數:
以下是 SOAP 1.2 請求和響應示例。所顯示的占位符需替換為實際值。
復制代碼 代碼如下:
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>

php技術PHP使用SOAP調用.net的WebService數據,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 东莞市| 福安市| 从化市| 贵南县| 米易县| 溧阳市| 灌云县| 靖西县| 英德市| 望城县| 海门市| 磴口县| 永嘉县| 宕昌县| 南开区| 广德县| 南投市| 罗田县| 台湾省| 阳西县| 滦南县| 邹城市| 张家港市| 桐城市| 苍梧县| 安宁市| 华蓥市| 武清区| 射洪县| 竹山县| 洞口县| 昌江| 淮南市| 河曲县| 观塘区| 鄂温| 大田县| 潞西市| 光山县| 吉木乃县| 垣曲县|