Keys:
- Datetime formate: 1961-12-21T00:00:00
-
The way to pass parameters to .Net web service is very weird:
array($params)
array('parameters'=>$params) -
Response will be an object of stdClass, not XML!
Well, I think this is weird but convenient to handle the response values.
Regerence:
- http://tw1.php.net/manual/ro/class.soapclient.php
-
wizdl: Amazing tool to test .Net web services:
http://wizdl.codeplex.com/ -
SOAP Client:
http://www.soapclient.com/soapclient
PHP Example Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
error_reporting(E_ALL); ini_set('display_errors',1); ini_set('display_startup_errors',1); $soapClient = new SoapClient("http://www.tfmi.com.tw/pis/vehicle/ws/WebQuotationWS.asmx?wsdl"); // Setup the RemoteFunction parameters $params = array( //'parameters' => array( 'wsTradeTO' => array( 'plyInsTypeTOs' => array( 'PlyInsTypeTO' => array( 'isSkipCalculate' => 0, 'insType' => '210', 'chDamageCover' => '', //Optional //'chDeathCover' => '', //Optional //'chInjuredCover' => '', //Optional //'cmnNt' => '', //Optional //'commission' => '', //Optional //'commissionRate' => '', //Optional 'damageCover' => 2000000, 'deathCover' => 2000000, 'deduct' => 0, 'discount' => 0, //'discountRate' => 0, //Optional 'drate' => '0001-01-01T00:00:00', 'injuredCover' => 200000 //'prem' => '', //Optional //'premiumMan' => '', //Optional //'premium' => '', //Optional //'srvFee' => '', //Optional //'baseDangerPrem' => '', //Optional //'stDangerPrem' => '', //Optional //'stDangerRate' => '', //Optional //'thisPremium' => '', //Optional //'prePremium' => '', //Optional //'drunkCnt' => '', //Optional //'exFactor1' => '', //Optional //'exFactor2' => '', //Optional //'exFactor3' => ''//Optional ) ), 'assuredBirth' => '1961-12-21T00:00:00', //'assuredBirth' => new soapval('assuredBirth', 'dateTime', '1961-12-21T00:00:00', false, 'http://www.w3.org/2001/XMLSchema'), //'applicantBirth' => '1961-12-21T00:00:00', //optional //'applyDateTime' => '2013-12-21T00:00:00', //optional 'assuredId' => 'N222023654', 'assuredSex' => '2', //'branchPassDateTime' => '2013-12-21T00:00:00', //optional 'brand' => 'MC001000', //'brgAlign' => '', //optional //'brgFactor' => '', //optional //'broker60' => '', //Optional 'broker66' => '99', //'c010Clm' => '', //Optional //'c010Pnt' => '', //Optional //'c210NSeq' => '', //Optional //'c210NSeqMan' => '', //Optional //'c210OSeq' => '', //Optional //'c210Prem' => '', //Optional //'c210DrunkCnt' => '', //Optional //'c210DrunkPrem' => '', //Optional //'c310Clm' => '', //Optional //'c310Grd' => '', //Optional //'c310NSeq' => '', //Optional //'c310OSeq' => '', //Optional //'c310NSeqMan' => '', //Optional 'carPrice' => 0, //'carType60' => '', //Optional 'carType66' => '01', //'cylinder' => 2000, //Optional //'dmgAccFactor' => '', //Optional //'dmgAcCnt1' => '', //Optional //'dmgAcCnt2' => '', //Optional //'dmgAcCnt3' => '', //Optional //'dmgAlign' => '', //Optional //'dmgFactor' => '', //Optional //'edrBegin60' => '', //Optional 'edrBegin66' => '2014-08-13T00:00:00', //'edrDate' => '2014-07-25T00:00:00', //Optional //'edrEnd60' => '', //Optional 'edrEnd66' => '2015-08-13T00:00:00', //'edrPeriod60' => '', //Optional //'edrPeriod66' => 12, //Optional //'edrPre' => '', //Optional //'edrSeq' => '', //Optional //'entryDate' => '', //Optional //'expAlign' => '', //Optional //'fpt60' => '', //Optional 'fpt66' => 'P', 'issueYM' => '199707', //'liaAccFactor' => '', //Optional //'liaAcCnt1' => '', //Optional //'liaAcCnt2' => '', //Optional //'liaAcCnt3' => '', //Optional //'liaAlign' => '', //Optional //'mngAlign' => '', //Optional //'officer60' => '', //Optional 'officer66' => '1166', 'isPublicOfficerType60' => 0, 'isPublicOfficerType66' => 0, 'isOpenCover' => 0, //'plyPassDateTime' => '', //Optional 'proMonth' => '07', 'proYear' => '1997', //'qpt60' => '', //Optional 'qpt66' => 2, //'reinsPassDateTime' => '', //Optional //'savAlign' => '',//Optional //'scrapValue' => '', //Optional //'sexAgeFactor66' => '',//Optional //'sexAgeFactor60' => '', //Optional 'tag' => 'GOJ-329' //'updateDateTime' => ''//Optional ) //) ); // Call RemoteFunction () $error = 0; try { //下面兩種送出request方式都可以成功 //注意!傳送參數的設定不同! //$response = $soapClient->__call("WebQuatation", array($params)); $response = $soapClient->__soapCall("WebQuatation", array('parameters'=>$params)); //print_r($response); $result = $response->WebQuatationResult; echo $result->WebQuatationInsTypeList->WebQuatationInsType->premium; } catch (SoapFault $fault) { $error = 1; print($fault->faultcode); } // Kill the link to Soap unset($soapClient); |
Response Structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
stdClass Object ( [WebQuatationResult] => stdClass Object ( [status] => 1 [errorCode] => [errorMsg] => [WebQuatationTrade] => stdClass Object ( [c210No] => [c210Date] => [c210NSeq] => 4 [c210OSeq] => 4 [c210Prem] => 0 [c210Expiration] => [c210DrunkPrem] => 0 [c210drunkCnt] => 0 [cvanNo] => [cvanDate] => [c310NSeq] => 0 [c310OSeq] => 0 [c310Grd] => 0 [c010Pnt] => 0 [c310Clm] => 0 [c010Clm] => 0 [c24Clm] => 00 [sexAgeFactor66] => 0.92 [sexAgeFactor60] => 0 [dmgFactor] => 0 [brgFactor] => 0 [liaAccFactor] => 0 [dmgAccFactor] => 0 [scrapValue] => 0 ) [WebQuatationInsTypeList] => stdClass Object ( [WebQuatationInsType] => stdClass Object ( [icode] => 20 [model] => [drate] => 2014/3/1 [insType] => 210 [discount] => 0 [discountRate] => 0 [premium] => 658 [prem] => 658 [injuredCover] => 0 [deathCover] => 0 [damageCover] => 0 ) ) ) ) |