DHL,肥皂,PHP - 不理解

时间:2012-10-31 20:07:46

标签: php soap soapui

我必须使用PHP向DHL运营商服务生成SOAP-Request以生成批处理标签。不知何故,我无法理解它是如何工作的。我写了这段代码:

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

?> 

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

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

你能帮我个忙吗?

2 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:0)

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

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

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

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

相关问题