【问题标题】:Pass longList argument to TECDOC webservice from php将 longList 参数从 php 传递给 TECDOC webservice
【发布时间】:2014-10-01 18:03:06
【问题描述】:

我正在处理关于 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 了解每个函数数据类型的详细信息。

请帮助我。

【问题讨论】:

    标签: php arrays list soap soap-client


    【解决方案1】:

    您需要将数组转换为 tecdoc 列表类型。

    不过很简单,创建一个包含 2 个字段的 stdClass 对象。

    emptyarray

    empty 设置为 false 并将 array 设置为 carId 数组,例如

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

    最好创建一个将数组转换为上述对象结构的函数,如果array 为空或为空,empty 标志将设置为 true

    【讨论】:

      【解决方案2】:

      我可以看到如下输出。

      stdClass Object
      (
          [data] => stdClass Object
              (
                  [array] => Array
                      (
                      )
      
                  [empty] => 1
              )
      
          [status] => 200
          [statusText] => 
      )
      

      你好,

      我已尝试使用 CURL...通过使用 soapclient,longlist carIds 存在问题。所以我们可以处理 CURL 请求。

      得到以下输出。

      数组 ( [数据] => 数组 ( [数组] => 数组 ( [数组] => 数组 ( [0] => 数组 ( [carId] => 1116 [motorCodes] => 数组 ( [数组] => 数组 ( [数组] => 数组 ( [电机代码] => 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);
      

      谢谢, 高朗

      【讨论】:

      猜你喜欢
      • 2016-11-04
      • 2011-07-23
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-05
      相关资源
      最近更新 更多