2012-10-31 88 views
0

我必須使用PHP向DHL運營商服務部門提出SOAP-Request來生成批量標籤。不知何故,我不明白它是如何工作的。我寫了這個代碼:DHL,肥皂,PHP - 不理解

<?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>DE348705000</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>[email protected]</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>[email protected]</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程序找出一些東西,但我似乎不明白所有這些東西是如何工作的。

你能給我一些幫助嗎?

回答

2

您嘗試將您的SOAP請求發送至(https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp)的URL未用作Web Service端點 - 它是用於將您的客戶登錄到DHL Intraship客戶門戶的單點登錄URL(您可以手動提交parceldata)。

Web Service的端點是http://test-intraship.dhl.com/ws/1_0/de/ISService(來源:https://entwickler.dhl.de/group/ep/webservices/intraship/quick-start

0

您可能需要更多的信息,從DHL

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

要登錄這個網址,你需要用戶名和密碼,這些信息是不是順等:身份認證部分,你在肥皂通過:頭節點。

這個新的用戶名和密碼需要在新的「Zend_Soap_Client_Common」對象中設置。