Calling external https web services in AL

brimfredbrimfred Member Posts: 14
Hello,

I have the following code for consuming soap web services in AL.

RequestMessage.SetRequestUri(URL);
RequestMessage.Method('POST');
Content.GetHeaders(Headers);
Headers.Remove('Content-Type');
Headers.Add('Content-Type', ContentType);
Content.WriteFrom(XML_text);
RequestMessage.Content := Content;
WsHTTPClient.send(RequestMessage, ResponseMessage);
if not ResponseMessage.IsSuccessStatusCode() then
error(format(ResponseMessage.HttpStatusCode()) + ' , ' + ResponseMessage.ReasonPhrase());
if ResponseMessage.IsSuccessStatusCode() then
begin
ResponseMessage.Content().ReadAs(InStr);
while not instr.EOS() do begin
InStr.ReadText(ReadString);
OutString += ReadString;
end;

// do something with outstring

end
else
error(format(ResponseMessage.HttpStatusCode()));

It works ok for http web services but crashes on https.

Error from event log:

Type: System.Net.WebException
Status: SecureChannelFailure
Message: <ii>The request was aborted: Could not create SSL/TLS secure channel.</ii>
StackTrace:
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)

Do I need to change some ssl configuration on IIS or NAV server?

Thanks!

Answers

  • okioki Member Posts: 46
    Hi,
    have the same issue. Is there a solution yet?
  • AgannaloAgannalo Member Posts: 12
    edited 2018-07-18
    Update service tier to one that use TLS12 by default or use this code:
    ServicePointManager=System.Net.ServicePointManager
    SecurityProtocolType=System.Net.SecurityProtocolType
    ServicePointManager.SecurityProtocol := SecurityProtocolType.Tls12;
    
  • Maria-SMaria-S Member Posts: 90
    edited 2019-04-15
    But DotNet is not allowed in AL.
    And what does it mean - "update service tier to one that use TLS12"?
  • Maria-SMaria-S Member Posts: 90
    So does anybody know whether it is possible at all, to consume webservices that require SSL/TLS connection from AL?
Sign In or Register to comment.