0

我必须使用 PHP 向 DHL 承运人服务发出 SOAP 请求以生成批次标签。不知何故,我无法理解它是如何工作的。我写了这段代码:

<?php 

require_once('lib/Zend/Soap/Client.php');
require_once('lib/Zend/Soap/Client/Common.php');

$client = new Zend_Soap_Client('http://test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl',  
                        array(  
                                'soap_version'=>SOAP_1_1  
                                ,'encoding' => 'UTF-8'  
                                ,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE  
                                ,'location'=>'https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp' 

                        )  
                );  

$location = 'https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp'; 

$request = '
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:cis="http://dhl.de/webservice/cisbase" xmlns:de="http://de.ws.intraship">
<soap:Header><cis:Authentification><cis:user>magento</cis:user><cis:signature>m1a2$!</cis:signature><cis:accountNumber>5000000000</cis:accountNumber><cis:type>0</cis:type></cis:Authentification>
</soap:Header>
<soap:Body><de:CreateShipmentDDRequest>
<cis:Version>
<cis:majorRelease>1</cis:majorRelease>
<cis:minorRelease>0</cis:minorRelease></cis:Version><ShipmentOrder><SequenceNumber>1</SequenceNumber><Shipment><ShipmentDetails><ProductCode>EPN</ProductCode><ShipmentDate>2012-10-03</ShipmentDate><DeclaredValueOfGoods>10.2</DeclaredValueOfGoods><DeclaredValueOfGoodsCurrency>EUR</DeclaredValueOfGoodsCurrency><cis:EKP>5000000000</cis:EKP><Attendance><cis:partnerID>01</cis:partnerID></Attendance><CustomerReference>Auftrag 12883884</CustomerReference><ShipmentItem><WeightInKG>12</WeightInKG><LengthInCM>1</LengthInCM><WidthInCM>1</WidthInCM><HeightInCM>10</HeightInCM><PackageType>PK</PackageType></ShipmentItem><Service><ShipmentServiceGroupIdent><ReturnReceipt>false</ReturnReceipt></ShipmentServiceGroupIdent></Service><Service><ShipmentServiceGroupIdent><Personally>false</Personally></ShipmentServiceGroupIdent></Service><Service><ServiceGroupDHLPaket><Multipack>False</Multipack></ServiceGroupDHLPaket></Service><BankData><cis:accountOwner>DHL.de</cis:accountOwner><cis:accountNumber>1234567891</cis:accountNumber><cis:bankCode>87050000</cis:bankCode><cis:bankName>Sparkasse Chemnitz</cis:bankName><cis:iban>DE34870500001234567891</cis:iban><cis:note>Notiz Bank</cis:note><cis:bic>CHEKDE81XXX</cis:bic></BankData></ShipmentDetails><Shipper><Company><cis:Person><cis:firstname></cis:firstname><cis:lastname>Deutsche Post IT BRIEF GmbH</cis:lastname></cis:Person></Company><Address><cis:streetName>Heinrich-Brüning-Str.</cis:streetName><cis:streetNumber>7</cis:streetNumber><cis:Zip><cis:germany>53113</cis:germany></cis:Zip><cis:city>Bonn</cis:city><cis:Origin><cis:countryISOCode>DE</cis:countryISOCode></cis:Origin></Address><Communication><cis:phone>3935644</cis:phone><cis:email>dhl@dhl.com</cis:email><cis:contactPerson>IT Systeme Marketing  Vertrieb</cis:contactPerson></Communication></Shipper><Receiver><Company><cis:Company><cis:name1>DHL Vertriebs GmbH Co. OHG</cis:name1></cis:Company></Company><Address><cis:streetName>Neue Poststr.</cis:streetName><cis:streetNumber>1</cis:streetNumber><cis:Zip><cis:other>08496</cis:other></cis:Zip><cis:city>Neumark</cis:city><cis:Origin><cis:countryISOCode>DE</cis:countryISOCode></cis:Origin></Address><Communication><cis:phone>3935655</cis:phone><cis:email>dhl@dhl.com</cis:email><cis:contactPerson>CIS 1J4</cis:contactPerson></Communication></Receiver><ExportDocument><InvoiceType>proforma</InvoiceType><InvoiceDate>2012-10-03</InvoiceDate><InvoiceNumber>444444</InvoiceNumber><ExportType>1</ExportType><ExportTypeDescription>für Sonstiges</ExportTypeDescription><CommodityCode>8888888</CommodityCode><TermsOfTrade>CIP</TermsOfTrade><Amount>2000</Amount><Description>777777</Description><CountryCodeOrigin>DE</CountryCodeOrigin><AdditionalFee>3.12</AdditionalFee><CustomsValue>2.23</CustomsValue><CustomsCurrency>EUR</CustomsCurrency><PermitNumber>666666</PermitNumber><AttestationNumber>?</AttestationNumber><ExportDocPosition><Description>Harddisk</Description><CountryCodeOrigin>DE</CountryCodeOrigin><CommodityCode>123456</CommodityCode><Amount>200</Amount><NetWeightInKG>1</NetWeightInKG><GrossWeightInKG>1.2</GrossWeightInKG><CustomsValue>200</CustomsValue><CustomsCurrency>EUR</CustomsCurrency></ExportDocPosition></ExportDocument></Shipment><LabelResponseType>URL</LabelResponseType></ShipmentOrder></de:CreateShipmentDDRequest></soap:Body></soap:Envelope>
';

$clientCommon = new Zend_Soap_Client_Common($client, 'http://test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl',  
                        array(  
                                'soap_version'=>SOAP_1_1  
                                ,'encoding' => 'UTF-8'  
                                ,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE  
                                ,'location'=>'https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp' 

                        ));  
    $response =  $client->_doRequest($clientCommon, trim($request), $location, 'createShipmentDD', SOAP_1_1);  

    print_r($response);

?> 

XML 代码是从 DHL 测试工具中复制的,访问数据是标准测试数据,实际上应该始终有效。但我总是变成“错误的登录数据”——消息。为什么会这样?

我试图用 SoapUI 程序找出一些东西,但我似乎不明白所有这些东西是如何工作的。

你能给我一些帮助吗?

4

2 回答 2

2

您尝试将 SOAP 请求发送到 ( https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp) 的 URL 未用作 Web 服务端点 - 它是用于将您的客户登录到 DHL Intraship 客户门户的单点登录 URL(您可以在那里手动提交包裹数据) .

Web 服务的端点是http://test-intraship.dhl.com/ws/1_0/de/ISService(来源:https ://entwickler.dhl.de/group/ep/webservices/intraship/quick-start )

于 2012-11-03T19:01:42.993 回答
0

您可能需要 DHL 提供的更多信息

https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp

要登录此 URL,您需要用户名和密码,此信息不是您在 soap:Header 节点中传递的 cis:Authentification 部分。

您需要在新的“Zend_Soap_Client_Common”对象中设置这个新的用户名和密码。

于 2012-11-01T10:51:55.553 回答