国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

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

2024-05-04 23:19:31
字體:
供稿:網(wǎng)友
這個與一般的PHP POST或GET傳值再查庫拿數(shù)據(jù)的思路有點不一樣,需要用到SOAP模塊,處理方法也很簡單,就是有一些需要注意的事情。
首先確認你的PHP.ini開啟了.SOAP,就是 extension=php_soap.dll 這前面的分號去咯。
代碼很簡單:

復(fù)制代碼 代碼如下:


<?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);
}
?>


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

復(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>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 高州市| 江口县| 莆田市| 修水县| 武宣县| 徐汇区| 呼图壁县| 新疆| 朝阳市| 酉阳| 益阳市| 论坛| 高邑县| 康保县| 瑞金市| 舒兰市| 林口县| 玛沁县| 朝阳区| 博白县| 阳东县| 定南县| 琼海市| 西乌珠穆沁旗| 百色市| 喀喇| 乳山市| 天峻县| 库伦旗| 郴州市| 自治县| 商洛市| 延边| 屏边| 丰原市| 壤塘县| 南漳县| 玉树县| 论坛| 咸丰县| 柳林县|