I'm trying to integrate the DHL CreateShipmentOrder API. When I send the document prepared by DHL with the Soap UI program, it works correctly. My code and the returned result are as follows. When I contacted DHL, I could not reach the result. Can you help me ?
I'm trying to integrate the DHL CreateShipmentOrder API. When I send the document prepared by DHL with the Soap UI program, it works correctly. My code and the returned result are as follows. When I contacted DHL, I could not reach the result. Can you help me ?
My Code;
public static void Main()
{
// Create Web request to get title elements
var serviceUrl = "https://cig.dhl.de/services/production/soap";
HttpWebResponse response = null;
try
{
String sPayload = String.Format(@"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:cis='http://dhl.de/webservice/cisbase' xmlns:ns='http://dhl.de/webservices/businesscustomershipping/3.0'>
<soapenv:Header>
<cis:Authentification>
<cis:user>*****</cis:user>
<cis:signature>*******</cis:signature>
</cis:Authentification>
</soapenv:Header>
<soapenv:Body>
<ns:CreateShipmentOrderRequest>
<ns:Version>
<majorRelease>3</majorRelease>
<minorRelease>1</minorRelease>
</ns:Version>
<ShipmentOrder>
<sequenceNumber/>
<Shipment>
<ShipmentDetails>
<product>V01PAK</product>
<cis:accountNumber>********</cis:accountNumber>
<customerReference>Ref. 123456</customerReference>
<shipmentDate>2022-01-06</shipmentDate>
<ShipmentItem>
<weightInKG>5</weightInKG>
<lengthInCM>60</lengthInCM>
<widthInCM>30</widthInCM>
<heightInCM>15</heightInCM>
</ShipmentItem>
<Notification> <recipientEmailAddress>[email protected]</recipientEmailAddress>
</Notification>
</ShipmentDetails>
<Shipper>
<Name>
<cis:name1>Absender Zeile 1</cis:name1>
<cis:name2>Absender Zeile 2</cis:name2>
<cis:name3>Absender Zeile 3</cis:name3>
</Name>
<Address>
<cis:streetName>Vegesacker Heerstr.111</cis:streetName>
<cis:zip>28757</cis:zip>
<cis:city>Bremen</cis:city>
<cis:Origin>
<cis:country/>
<cis:countryISOCode>DE</cis:countryISOCode>
</cis:Origin>
</Address>
<Communication>
<!--Optional:-->
<cis:phone>+49421987654321</cis:phone>
<cis:email>[email protected]</cis:email>
<!--Optional:-->
<cis:contactPerson>Kontaktperson Absender</cis:contactPerson>
</Communication>
</Shipper>
<Receiver>
<cis:name1>Empfänger Zeile 1</cis:name1>
<Address>
<cis:name2>Empfänger Zeile 2</cis:name2>
<cis:name3>Empfänger Zeile 3</cis:name3>
<cis:streetName>An der Weide 50a</cis:streetName>
<cis:zip>28195</cis:zip>
<cis:city>Bremen</cis:city>
<cis:Origin>
<cis:country/>
<cis:countryISOCode>DE</cis:countryISOCode>
</cis:Origin>
</Address>
<Communication>
<cis:phone>+49421123456789</cis:phone>
<cis:email>[email protected]</cis:email>
<cis:contactPerson>Kontaktperson Empfänger</cis:contactPerson>
</Communication>
</Receiver>
</Shipment>
<PrintOnlyIfCodeable active='1'/>
</ShipmentOrder>
<labelResponseType>URL</labelResponseType>
<combinedPrinting>0</combinedPrinting>
</ns:CreateShipmentOrderRequest>
</soapenv:Body>
</soapenv:Envelope>");
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(serviceUrl) as HttpWebRequest;
webRequest.ContentType = "text/xml;charset=utf-8";
webRequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("******:*****"));
webRequest.Method = "POST";
using (var sw = new StreamWriter(webRequest.GetRequestStream()))
{
sw.Write(sPayload);
sw.Close();
}
response = (HttpWebResponse) webRequest.GetResponse();
}
catch (WebException ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
finally
{
if (response != null)
Console.WriteLine("Http status = " + response.StatusCode + " - " + response.StatusDescription);
}
if( response != null && response.StatusDescription == "OK" ) {
Console.WriteLine("Successfull");
}
Console.WriteLine(DateTime.Now.ToString());
}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>SECURITY_VIOLATION</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>