代码发送到主机webservice
$client = new SoapClient("http://27.131.163.203/testws/service.asmx?wsdl",
array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 0, // disable exceptions
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server
);
$methodName = 'CallTHI';
$params = array('Language'=>'TH');
$params = array('encoding' => 'UTF-8',
rpcNumber => '103',
inStr => '<EFF_DATE>'.$newDate1.'</EFF_DATE><EXP_DATE>'.$newDate2.'</EXP_DATE><VEHICLE_MODEL>'.$row['asmodel_id'].'</VEHICLE_MODEL><YEAR_MADE>'.$row['caryear'].'</YEAR_MADE>
<DISP>'.$row['carsize'].'</DISP><WEIGHT></WEIGHT><SEAT></SEAT><VEHICLE_PROV>'.$row['carprov'].'</VEHICLE_PROV><VEHICLE_TYPE>'.$row['codetype'].'</VEHICLE_TYPE>
<PLAN_CODE>S110/1YA</PLAN_CODE><TITLE>'.$row['astitle_id'].'</TITLE><FIRST_NAME>'.$row['FNameTH'].'</FIRST_NAME>
<LAST_NAME>'.$row['LNameTH'].'</LAST_NAME><MOBILE_NO>'.$row['Mobile'].'</MOBILE_NO><TEL_NO>'.$oTel.'</TEL_NO><ADDRESS>'.$CustAddr.'</ADDRESS>
<PROVINCE>'.$row['prov_id'].'</PROVINCE><AMPHOE>'.$row['amp_code'].'</AMPHOE><POST_CODE>'.$row['Zip'].'</POST_CODE><VEH_NBR>'.$carLicense.'</VEH_NBR>
<CHASSIS_NBR>'.$row['carboxno'].'</CHASSIS_NBR><AGENT_CODE>'.$agentID.'</AGENT_CODE><COUNTER_CODE>'.$cntCODE.'</COUNTER_CODE><ISSUE_OFF>0110</ISSUE_OFF><USER_ID>AUTO.WS</USER_ID>
<ENGINE_NBR>'.$carNO.'</ENGINE_NBR><ID_NBR>'.$row['IDCard'].'</ID_NBR><CHK_IDCARD>IDCARD</CHK_IDCARD><CHK_BRANCH></CHK_BRANCH>'
) ;
$soapAction = 'http://27.131.163.203/testws/service.asmx?op=CallTHI';
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$data = $client->CallTHI($params);
将xml转换为字符串
$simple = $data->CallTHIResult; // or $simple = $client->__getLastResponse();
$xmlStr = file_get_contents($simple);
$transaction = simplexml_load_file($xmlStr);
页面显示错误:
Warning: file_get_contents(<TRAN_ID>17567_50959.5512_3086</TRAN_ID><TRAN_DATE>20160204</TRAN_DATE><TRAN_TIME>14:09:19</TRAN_TIME><ERROR_CODE>1</ERROR_CODE><ERROR_DESC>Not Input Policy</ERROR_DESC><POLICY_NBR></POLICY_NBR><URL_POLICY>http://aiiapp.asiainsurance.co.th/THI_WEB2/webprint/.pdf</URL_POLICY>): failed to open stream: Invalid argument in C:\AppServ\www\Prakan\productpopup\test.php on line 234 Warning: simplexml_load_file(): I/O warning : failed to load external entity "" in C:\AppServ\www\Prakan\productpopup\test.php on line 235