2

我是编程初学者,并且遇到了肥皂电话问题。

我想从 DHL 获得基于 64 位的货件标签。我通常与 Rest 合作,但 DHL 在德国只有 SOAP。

我收到此错误:

SOAP-ENV:ServerUncaught SoapFault 异常:[soap:Receiver] UNKNOWN_ERROR in /homepages/12/d573220848/htdocs/beta/dhl/index.php:90 堆栈跟踪:#0 /homepages/12/d573220848/htdocs/beta/dhl /index.php(90): SoapClient->__soapCall('createShipmentO...', Array, Array) #1 {main} 抛出

我认为身份验证有效

这是我作为客户端的 php 代码

$wsdl = 'https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/2.2/geschaeftskundenversand-api-2.2.wsdl';
  $params = array(
      'location' => "https://cig.dhl.de/services/sandbox/soap", 
      'uri' => "https://",
      'login' => "*userid*",
      'password' => "*secret_password*",
      'soap_version' => SOAP_1_2,
      'exceptions' => True,
      'trace' => 1
  );

  $client = new SoapClient($wsdl, $params);
  $header = new SoapHeader("https://cig.dhl.de/services/sandbox/soap", "authentication", "Basic [EDITED]"); 
  use_soap_error_handler(true);
  //Funktionen und Typen anfragen
  echo '<h3>Funktionen</h3>';
  $functions = $client->__getFunctions();
  foreach($functions as $d){
      echo "<br>".$d;
  }
  echo '<br><h3>Types</h3>';
  $types = $client->__getTypes();
  foreach($types as $t){
      echo "<br>".$t;
  }
  echo '<br><br>';


  $request = array(
      'CreateShipmentOrderRequest' => "1",
          'Version' => array(
          'majorRelease' => "2",
          'minorRelease' => "0"),
      'ShipmentOrder' => array(
      'SequenceNumber' => "01",
          'Shipment' => array(
          'ShipmentDetails' => array(
          'product' => "V01PAK",
          'accountNumber' => "22222222220101")))

  );

  //RESPONSE
  $response = $client ->__soapCall("createShipmentOrder", $request, $params);
  var_dump($response);
  echo '<br><br>';

我得到了所有的类型和功能,但没有要求。这是来自dhl的纪录片:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:cis="http://dhl.de/webservice/cisbase"
               xmlns:bcs="http://dhl.de/webservices/businesscustomershipping"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Header>
        <cis:Authentification>
            <cis:user>2222222222_01</cis:user>
            <cis:signature>pass</cis:signature>
        </cis:Authentification>
    </soap:Header>
    <soap:Body>
    ...
    </soap:Body>
</soap:Envelope>

Die Abrechnungsnummern müssen zusammen mit dem Produkt im SOAP-Body im Type "Shipment Details" eingetragen werden:

</soap:Header>
    <soap:Body>
        <bcs:CreateShipmentOrderRequest>
            <cis:Version>
                <cis:majorRelease>2</cis:majorRelease>
                <cis:minorRelease>0</cis:minorRelease>
            </cis:Version>
            <ShipmentOrder>
                <SequenceNumber>01</SequenceNumber>
                <Shipment>
                    <ShipmentDetails>
                        <product>V01PAK</product>
                        <cis:accountNumber>22222222220101</cis:accountNumber>

我该怎么做才能让它发挥作用?

4

1 回答 1

1

我使用了您的代码中的一部分,示例 DHL 中的一部分并且有结果。我希望这对你有帮助。我也有为 DHL API 开发 SOAP 客户端的任务,如果您对此有更多示例或问题,我将不胜感激。示例数据 getVersion 请求http://prntscr.com/i5jepf

$wsdl =  'https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/2.2/geschaeftskundenversand-api-2.2.wsdl';   
$sandbox = "https://cig.dhl.de/services/sandbox/soap";  
$user = "******";
$password = "*******";  
$options = array(
  'location' => $sandbox, 
  'uri' => "",
  'login' => $user,
  'password' => $password,
  'soap_version' => SOAP_1_1,
  'exceptions' => false,
  'trace' => 1
);  
$client = new SoapClient($wsdl,$options);   
$request ='Sample data getVersion install here';
$result = $client->__doRequest($request,$sandbox, 'getVersion',1);
if (is_soap_fault($result)) {
   trigger_error("Error SOAP: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}   
var_dump($result);  
string(512) " 2 2 8 "
于 2018-01-25T18:24:26.570 回答