我正在使用TECDOC上的项目。在这里了解TECDOC http://webservicepilot.tecdoc.net/pegasus-2-0/。
所以在这个页面上http://webservicepilot.tecdoc.net/pegasus-2-0/test2/index.html 在下拉菜单中,您将找到函数 getVehicleByIds(), getVehicleByIds2(), getVehicleByIds2StringList() 和getVehicleByIdsStringList()。
在上述功能中,您会找到 carIds 字段,其数据类型为 longList (前两个功能)或 StringList (对于其他两个函数)。
现在我从PHP调用此函数时,我必须在lonlList或StringList数据类型中传递此字段的参数,这在PHP中是不可用的,并且通常知道此任务通常使用php数组。但它在这里不起作用。
这是代码......
<?php
$url ="http://webservicepilot.tecdoc.net/pegasus-2-0/wsdl/TecdocToCat";
$trace = array('trace' => 1);
$client = new SoapClient($url, $trace);
$request_array = array(
'country'=>'pt',
'countryUserSetting'=>'CH',
'lang'=>'pt',
'motorCodes'=>true,
'provider'=>'452',
'vehicleTerms'=>true,
'carIds'=>1116,
'passengerCarDetails'=>true
);
echo "<pre>";
$responce = $client->getVehicleByIds($request_array);
print_r($responce);
?>
注意:我发布的第一个链接中提供了一些文档。 对于每个函数数据类型详细信息研究,请参阅 InterfaceCatService.pdf 。
请帮帮我。
答案 0 :(得分:1)
我可以看到如下的输出。
stdClass Object
(
[data] => stdClass Object
(
[array] => Array
(
)
[empty] => 1
)
[status] => 200
[statusText] =>
)
Hello Again,
我尝试使用CURL ...使用soapclient时,longlist carIds存在问题。所以我们可以使用CURL请求。
获得以下输出。
阵 ( [data] =&gt;排列 ( [array] =&gt;排列 ( [array] =&gt;排列 ( [0] =&gt;排列 ( [carId] =&gt; 1116 [motorCodes] =&gt;排列 ( [array] =&gt;排列 ( [array] =&gt;排列 ( [motorCode] =&gt; DZ )
)
[empty] => false
)
[passengerCarDetails] => Array
(
[brakeSystem] => Hidráulico
[constructionType] => três volumes
[cylinder] => 4
[cylinderCapacityCcm] => 1781
[cylinderCapacityLiter] => 180
[fuelType] => Gasolina
[fuelTypeProcess] => Injecção no colector de admissão/carburador
[impulsionType] => Tracção dianteira
[manuName] => AUDI
[modelName] => 80 (89, 89Q, 8A, B3)
[motorType] => Otto
[powerHP] => 112
[powerKW] => 82
[typeName] => 1.8 E
[typeNumber] => 1116
[valves] => 2
[yearOfConstructionFrom] => 198606
[yearOfConstructionTo] => 199108
)
[vehicleDetails] => Array
(
[axisConfiguration] => Array
(
[@value] =>
[@attributes] => Array
(
[nil] => true
)
)
[carId] => 1116
[ccmTech] => 1781
[constructionType] => três volumes
[manuId] => 5
[modId] => 31
[powerHpFrom] => 112
[powerHpTo] => 112
[powerKwFrom] => 82
[powerKwTo] => 82
[tonnage] => Array
(
[@value] =>
[@attributes] => Array
(
[nil] => true
)
)
[yearOfConstrFrom] => 198606
[yearOfConstrTo] => 199108
)
[vehicleTerms] => Array
(
[carId] => 1116
[carType] => 1.8 E
[manuId] => 5
[manuName] => AUDI
[modId] => 31
[modelName] => 80 (89, 89Q, 8A, B3)
)
)
[1] => Array
(
[carId] => 1117
[motorCodes] => Array
(
[array] => Array
(
[array] => Array
(
[motorCode] => SD
)
)
[empty] => false
)
[passengerCarDetails] => Array
(
[brakeSystem] => Hidráulico
[constructionType] => três volumes
[cylinder] => 4
[cylinderCapacityCcm] => 1847
[cylinderCapacityLiter] => 180
[fuelType] => Gasolina
[fuelTypeProcess] => Injecção no colector de admissão/carburador
[impulsionType] => Tracção dianteira
[manuName] => AUDI
[modelName] => 80 (89, 89Q, 8A, B3)
[motorType] => Otto
[powerHP] => 113
[powerKW] => 83
[typeName] => 1.8
[typeNumber] => 1117
[valves] => 2
[yearOfConstructionFrom] => 198609
[yearOfConstructionTo] => 198807
)
[vehicleDetails] => Array
(
[axisConfiguration] => Array
(
[@value] =>
[@attributes] => Array
(
[nil] => true
)
)
[carId] => 1117
[ccmTech] => 1847
[constructionType] => três volumes
[manuId] => 5
[modId] => 31
[powerHpFrom] => 113
[powerHpTo] => 113
[powerKwFrom] => 83
[powerKwTo] => 83
[tonnage] => Array
(
[@value] =>
[@attributes] => Array
(
[nil] => true
)
)
[yearOfConstrFrom] => 198609
[yearOfConstrTo] => 198807
)
[vehicleTerms] => Array
(
[carId] => 1117
[carType] => 1.8
[manuId] => 5
[manuName] => AUDI
[modId] => 31
[modelName] => 80 (89, 89Q, 8A, B3)
)
)
)
)
[empty] => false
)
)
以下是使用CURL获取响应的代码。
$soap_request = "<?xml version=\"1.0\"?>\n";
$soap_request .= '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://path- to/schemas" xmlns:urn="urn:axis.server.cat.tecdoc.net" xmlns:car="http://carselection.datatype.tocinterface.cat.tecdoc.net" xmlns:dat="http://datatype.cat.tecdoc.net" xmlns:tec="http://webservicepilot.tecdoc.net/pegasus-2-0/services/TecdocToCatWL">
<soapenv:Header/>
<soapenv:Body>
<urn:getVehicleByIds>
<urn:in0>
<car:carIds>
<dat:array>
<tec:item>1116</tec:item>
<tec:item>1117</tec:item>
</dat:array>
</car:carIds>
<car:country>pt</car:country>
<car:countryUserSetting>CH</car:countryUserSetting>
<car:lang>pt</car:lang>
<car:motorCodes>true</car:motorCodes>
<car:passengerCarDetails>true</car:passengerCarDetails>
<car:provider>292</car:provider>
<car:vehicleTerms>true</car:vehicleTerms>
</urn:in0>
</urn:getVehicleByIds>
</soapenv:Body>
</soapenv:Envelope>';
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($soap_request),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "http://webservicepilot.tecdoc.net/pegasus-2- 0/services/TecdocToCatWL?wsdl" );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_PROXY, IF_ANY);
$result = curl_exec($soap_do);
谢谢, GAURANG
答案 1 :(得分:0)
您需要将数组转换为tecdoc列表类型。
虽然非常简单,但要创建一个包含2个字段的stdClass
对象。
empty
和array
将empty
设置为false,将array
设置为carIds数组,如
$carIds = array(1116);
$obj = new stdClass();
$obj->empty = false;
$obj->array = $carIds;
现在在SOAP请求的参数列表中传递$ obj
$request_array = array(
'country'=>'pt',
'countryUserSetting'=>'CH',
'lang'=>'pt',
'motorCodes'=>true,
'provider'=>'292',
'vehicleTerms'=>true,
'carIds'=> $obj,
'passengerCarDetails'=>true
);
更好地创建一个将数组转换为上面的对象结构的函数,如果empty
为null或为空,则array
标志将设置为true