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
|

