HTTPConnection.Post - DHL API

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
1C:Professional
Rating: 1
Joined: Mar 7, 2016
Company: 4b-software UG

Hi
I try to connect the DHL API with HHTPConnection.Post. This works with both Postman and SoadUI. Unfortunately, 1C HTTPConnection.Post returns the error message "Internet error: Failure when receiving data from the peer". I don't know why.

Does anyone have an idea, or can help with it?

Thank you in advance.
Michael


Here's my code:

Code
&AtServer
Procedure DHLGetVersionServer()
   
    //URL = "https://cig.dhl.de/services/sandbox/soap/";
   
    DHLServer = "cig.dhl.de";
    SOAPServicesEndpoint = "/services/sandbox/soap";
    User = Constants.User.Get();
    Password = Constants.Password.Get();
   
    Version = New Structure("majorRelease, minorRelease, build", "3", "0", "0");
    RequestFile = GetVersionXMLFileName(Version);
    // RequestFile content:
    //<soapenv:Envelope xmlns:ns="http://dhl.de/webservices/businesscustomershipping/3.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    //   <soapenv:Header/>
    //   <soapenv:Body>
    //      <ns:Version>
    //         <majorRelease>3</majorRelease>
    //         <minorRelease>0</minorRelease>
    //         <build>0</build>
    //      </ns:Version>
    //   </soapenv:Body>
    //</soapenv:Envelope>

    ProxyServer = New InternetProxy;
    ProxyServer.Set("https", DHLServer, , User, Password); 
   
    SecureConnection = New OpenSSLSecureConnection;
   
    Try
        Connection = New HTTPConnection(DHLServer,,,, ProxyServer, , SecureConnection);
    Except
        Message("Couldn't connect to DHL server:" + Chars.LF + BriefErrorDescription(ErrorInfo()));
        Return;
    EndTry;
   
    // send request
    // ResponseFile content should be:
    //<soapenv:Envelope xmlns:bus="http://dhl.de/webservices/businesscustomershipping/3.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    //       <soapenv:Header/>
    //       <soapenv:Body>
    //           <bus:GetVersionResponse>
    //               <bus:Version>
    //                   <majorRelease>3</majorRelease>
    //                   <minorRelease>0</minorRelease>
    //                   <build>0</build>
    //               </bus:Version>
    //           </bus:GetVersionResponse>
    //       </soapenv:Body>
    //</soapenv:Envelope>
   
    RequestHeaders = New Map;
    RequestHeaders["Content-Type"] = "text/xml;charset=UTF-8";
    RequestHeaders["SOAPAction"] = "urn:getVersion";
   
    HTTPRequest = New HTTPRequest(SOAPServicesEndpoint, RequestHeaders);
    HTTPRequest.SetBodyFileName(RequestFile);
   
    ResponseFile = "D:\Temp\Response.txt";
   
    Try
        Result = Connection.Post(HTTPRequest, ResponseFile);
    Except
        Message(BriefErrorDescription(ErrorInfo()));
    EndTry;
   
EndProcedure

 
#2
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Sep 7, 2019
Company:

Just a guess: no internet on the machine, where your application server is installed?

You run Postman and SoadUI on our local client machine and the code, obviously, is running on the application server (&AtServer directive).

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.