“Metadata contains a Reference cannot be resolved” error for WCF service

This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.

While trying to make a WCF service to connect Dynamics 365, I came across to this error message:

 

Message Metadata contains a reference that cannot be resolved: ‘https://dynamics.com/test.svc?wsdl&sdkversion=9’. >> StackTrace at System.ServiceModel.Description.MetadataExchangeClient. MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)\r\n

 

Nedim_1-1606776487439.jpeg

 

We also saw the error below during testing:

 

InnerException System.Net.WebException: Unable to connect to the remote server —> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

 

Root Cause

 

Dynamics 365 started requiring TLS 1.2 after version 9.x (Reference). Connections that don’t use TLS 1.2 started failing after this update.

 

Solution

 

Force WCF service to use TLS 1.2 to solve this issue. One way of forcing it is to use the following line in the application:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

 

 

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.