PHP SOAP V.S. .Net Web Service

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:

PHP Example Code:

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:

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 
			) 
		) 
	) 
)