即使我是php soap概念的新手,我也会编写一个程序来使用SoapClient来传送Web服务器。
这是我的wsdl链接: https://es.adpolice.gov.ae/TrafficInsurance/TrafficInsuranceServicesNew.asmx?wsdl
服务名称:CreateVehicleInsurancePolicy 链接:https://es.adpolice.gov.ae/TrafficInsurance/TrafficInsuranceServicesNew.asmx?op=CreateVehicleInsurancePolicy
我在ssl认证的托管中托管我的程序。当它运行时,在soap body响应中生成响应( lngSerial )。我想从soap标头打印响应值( SoapHeaderOut )。
intResponseCode,strArMsg,strEnMsg 。
请指导我。我正在提供我正在使用的剧本。
<?php
ini_set("soap.wsdl_cache_enabled", "0");
ini_set("soap.wsdl_cache_ttl", "0");
class SOAPStruct
{
function __construct($user, $pass)
{
$this->userName = $user;
$this->Password = $pass;
}
}
$service = new SoapClient("https://es.adpolice.gov.ae/TrafficInsurance/TrafficInsuranceServicesNew.asmx?wsdl");
$auth = new SOAPStruct('username','password');
$header = new SoapHeader("http://adpolice.gov.ae/TrafficInsurance/TrafficInsuranceServices.asmx","SoapHeaderIn",$auth,true);
$service->__setSoapHeaders($header);
$param = array('lngInsuranceCompanyCode'=> '1','intInsuranceKindCode'=>'1','lngTcf'=>'3070858641','strPolicyNo'=>'1055385883','dtExpiryDate'=>'2016-04-30T00:00:00','dtStartDate'=>'2015-03-31T00:00:00','strChassisNo'=>'6T1BE42RG465465','strRemarks'=>'demo','strUserCreated'=>'demo');
$response = $service->CreateVehicleInsurancePolicy($param)->CreateVehicleInsurancePolicyResult;
foreach ($response as $record) {
print_r($record);
print_r("<br>");
}
?>
答案 0 :(得分:0)
根据PHP文档,您应该能够通过使用低级API而不是WSDL提供的魔术方法来获取SoapHeader响应对象。在你的情况下,它将是
$response = $service->__soapCall("CreateVehicleInsurancePolicy", $param, null, $headers, $response_headers);
哪个应该将您想要的对象存储到$ response_headers变量中。
旧响应:(与响应的实际HTTP标头有关) 如果使用跟踪集实例化SoapClient,那么:
$service = new SoapClient("https://es.adpolice.gov.ae/TrafficInsurance/TrafficInsuranceServicesNew.asmx?wsdl", array("trace" => 1))
您应该能够使用SoapClient::__getLastResponseHeaders
获取标头响应$response_headers = $service->__getLastResponseHeaders();