AX – D365FO – Consuming a TLS 1.2 web service

When consuming a web service from AX this error can occour:

System.ServiceModel.CommunicationException: An error occurred while making the HTTP request to ……… This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. —> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. —> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.

This error indicates that the web service has TLS 1.2 security protocol enabled

In order to solve it you can  add this code before to call the web service in X++ :

//Add this code to enable TLS 1.2 security protocol    
System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);

//Then call Web service
request = new Praxedo.ServiceReference.LocationManager.getLocations(locations, wsEntryArr, credentials);
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s