简体   繁体   中英

DHL, Soap, PHP - not understanding

I have to make a SOAP-Request with PHP to the DHL Carrier Service to generate batch labels. Somehow, I can't understand how it works. I wrote this code:

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

?> 

The XML code is copied from the DHL test tool, the access data are standard test data, which should actually always work. But I always become a "Wrong login data"-message. Why can it be?

I tried to find something out with the SoapUI programm but I don't seem to understand how all this stuff work.

Can you please give me some help?

The URL you are trying sending your SOAP-Request to ( https://test-intraship.dhl.com/intraship.57/jsp/Login_WS.jsp ) is not used as an Web Service endpoint - it is the Single-Sign-On URL for logging in your customer to the DHL Intraship Customer Portal (you can submit parceldata manually there).

The endpoint for the Web Service is http://test-intraship.dhl.com/ws/1_0/de/ISService (Source: https://entwickler.dhl.de/group/ep/webservices/intraship/quick-start )

You may need more information from DHL

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

To Login this URL you need User name and password, This information is other than cis:Authentification section you passed in soap:Header node.

This new User name and password you need to set in new "Zend_Soap_Client_Common" object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM