C# DHL: getPaketboxesByAddress

Back to Index

getPaketboxesByAddress

Documentation: https://entwickler.dhl.de/en/group/ep/apis/standortsuche/operationen/getpaketboxesbyadress/beispieldaten

CURL Command

curl https://cig.dhl.de/services/sandbox/soap \
-u dhl_developer_id:dhl_developer_password \
-H "Content-Type: application/xml" \
-d '<soapenv:Envelope
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:web="http://postfinder.dpag.de/webservice">
 <soapenv:Header/>
 <soapenv:Body>
  <web:getPaketboxesByAddress>
   <!--Optional:-->
   <key></key>
   <address>
    <!--Optional:-->
    <street>Charles-de-Gaulle-Str.</street>
    <!--Optional:-->
    <streetNo>20</streetNo>
    <!--Optional:-->
    <zip>53113</zip>
    <!--Optional:-->
    <city>Bonn</city>
   </address>
  </web:getPaketboxesByAddress>
 </soapenv:Body>
 </soapenv:Envelope> '

C# Example

Chilkat.Rest rest = new Chilkat.Rest();
bool success;

//  URL: https://cig.dhl.de/services/sandbox/soap
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect("cig.dhl.de",port,bTls,bAutoReconnect);
if (success != true) {
    Debug.WriteLine("ConnectFailReason: " + Convert.ToString(rest.ConnectFailReason));
    Debug.WriteLine(rest.LastErrorText);
    return;
}

rest.SetAuthBasic("dhl_developer_id","dhl_developer_password");

//  See the Online Tool for Generating XML Creation Code
Chilkat.Xml xml = new Chilkat.Xml();
xml.Tag = "soapenv:Envelope";
xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/");
xml.AddAttribute("xmlns:web","http://postfinder.dpag.de/webservice");
xml.UpdateChildContent("soapenv:Header","");
xml.UpdateChildContent("soapenv:Body|web:getPaketboxesByAddress|key","");
xml.UpdateChildContent("soapenv:Body|web:getPaketboxesByAddress|address|street","Charles-de-Gaulle-Str.");
xml.UpdateChildContent("soapenv:Body|web:getPaketboxesByAddress|address|streetNo","20");
xml.UpdateChildContent("soapenv:Body|web:getPaketboxesByAddress|address|zip","53113");
xml.UpdateChildContent("soapenv:Body|web:getPaketboxesByAddress|address|city","Bonn");

rest.AddHeader("Content-Type","application/xml");

Chilkat.StringBuilder sbRequestBody = new Chilkat.StringBuilder();
xml.GetXmlSb(sbRequestBody);
Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
success = rest.FullRequestSb("POST","/services/sandbox/soap",sbRequestBody,sbResponseBody);
if (success != true) {
    Debug.WriteLine(rest.LastErrorText);
    return;
}

int respStatusCode = rest.ResponseStatusCode;
if (respStatusCode >= 400) {
    Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(rest.ResponseHeader);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(sbResponseBody.GetAsString());
    return;
}

Chilkat.Xml xmlResponse = new Chilkat.Xml();
xmlResponse.LoadSb(sbResponseBody,true);

//  See the Online Tool for Generating XML Parse Code
string S_Envelope_xmlns_S;
string ns2_getPaketboxesByAddressResponse_xmlns_ns2;
int i;
int count_i;
string paketbox_packstationId;
string paketbox_objectId;
string paketbox_id;
string tagPath;
int automatType;
int positionType;
int opStatusType;
string hasXLPostfach;
string street;
int streetNo;
int zip;
string city;
string district;
string country;
string latitude;
string longitude;
int distance;

S_Envelope_xmlns_S = xmlResponse.GetAttrValue("xmlns:S");
ns2_getPaketboxesByAddressResponse_xmlns_ns2 = xmlResponse.ChilkatPath("S:Body|ns2:getPaketboxesByAddressResponse|(xmlns:ns2)");
i = 0;
count_i = xmlResponse.NumChildrenHavingTag("S:Body|ns2:getPaketboxesByAddressResponse|paketbox");
while (i < count_i) {
    xmlResponse.I = i;
    paketbox_packstationId = xmlResponse.ChilkatPath("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|(packstationId)");
    paketbox_objectId = xmlResponse.ChilkatPath("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|(objectId)");
    paketbox_id = xmlResponse.ChilkatPath("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|(id)");
    automatType = xmlResponse.GetChildIntValue("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|automatType");
    positionType = xmlResponse.GetChildIntValue("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|positionType");
    opStatusType = xmlResponse.GetChildIntValue("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|opStatusType");
    hasXLPostfach = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|hasXLPostfach");
    street = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|address|street");
    streetNo = xmlResponse.GetChildIntValue("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|address|streetNo");
    zip = xmlResponse.GetChildIntValue("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|address|zip");
    city = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|address|city");
    district = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|address|district");
    country = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|address|country");
    latitude = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|location|latitude");
    longitude = xmlResponse.GetChildContent("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|location|longitude");
    distance = xmlResponse.GetChildIntValue("S:Body|ns2:getPaketboxesByAddressResponse|paketbox[i]|location|distance");
    i = i + 1;
}

Sample XML Response Body

<?xml version="1.0" encoding="utf-8" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:getPaketboxesByAddressResponse xmlns:ns2="http://postfinder.dpag.de/webservice">
            <paketbox packstationId="0" objectId="120" id="500000120">
                <automatType>5</automatType>
                <positionType>0</positionType>
                <opStatusType>1</opStatusType>
                <hasXLPostfach>false</hasXLPostfach>
                <address>
                    <street>Rahm</street>
                    <streetNo>1</streetNo>
                    <zip>92431</zip>
                    <city>Neunburg vorm Wald</city>
                    <district>Neunburg</district>
                    <country>Deutschland</country>
                </address>
                <location>
                    <latitude>49.3476109711499</latitude>
                    <longitude>12.3846863483582</longitude>
                    <distance>11014</distance>
                </location>
                <timeinfos/>
            </paketbox>
            <paketbox packstationId="0" objectId="121" id="500000121"/>
        </ns2:getPaketboxesByAddressResponse>
    </S:Body>
</S:Envelope>