DynamicsNode
DynamicsNode copied to clipboard
Error trying to connect to Server: Metadata contains a reference that cannot be resolved
I tried your module on Linux Ubuntu 14.04 with latest Mono 4.2 calling external on premise dynamics crm 2015. When checking, if XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1 is available via url, it is accessible. I get following error, when trying to access it.
Error: Error trying to connect to Server: Metadata contains a reference that cannot be resolved : http://crmsrv.example.com:5555/XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1
System.InvalidOperationException: Metadata contains a reference that cannot be resolved : http://crmsrv.example.com:5555/XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1 ---> System.ServiceModel.EndpointNotFoundException: System error. ---> System.Net.WebException: Error: NameResolutionFailure
at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) <0x4025ab40 + 0x00117> in
@ariskemper It looks like a name resolution failure based on your trace.
System.ServiceModel.EndpointNotFoundException: System error. ---> System.Net.WebException: Error: NameResolutionFailure
Have you tried downloading the wsdl first, and check if there are references to other servers? Sometimes the wsdl has references to other data types (like .xsd files) which might be returned using server names.
Try adding those to your /etc/hosts file.
@ariskemper , this definitely looks like a network issue.
http://stackoverflow.com/questions/8999616/httpwebrequest-nameresolutionfailure-exception-in-net-with-mono-on-ubuntu
There are some tweaks in the above article that may help.
Anyway, would you be able to compile a .net console application to see if it connects well to your CRM server? I can send you the code if you want.
@crisfervil we will also try module with Dynamics CRM 2016. You could send me the .net console application code. Thanks
@ariskemper , is just a simple piece of code to test if it connects properly.
Add the CRM dlls, compile and run. If it connects successfully, the problem must be DynamicsIntegration.
References to be added, from CRM sdk:
Microsoft.Xrm.Client Microsoft.Xrm.Sdk Microsoft.Crm.Sdk.Proxy
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Client.Services;
using System;
using System.Net;
namespace DynamicsIntegrationTest
{
class Program
{
static void Main(string[] args)
{
string connectionString = "Url=http://crm.contoso.org/MyOrgName";
WebRequest.DefaultWebProxy = WebRequest.GetSystemWebProxy();
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
// Establish a connection to the organization web service using CrmConnection.
var connection = CrmConnection.Parse(connectionString);
var orgService = new OrganizationService(connection);
// Test the connection
var userId = ((WhoAmIResponse)orgService.Execute(new WhoAmIRequest())).UserId;
Console.WriteLine("Connection successful!");
Console.Read();
}
}
}
@crisfervil: Tested with Dynamics CRM 2016. Running this code i get:
Unhandled Exception:
System.InvalidOperationException: Metadata contains a reference that cannot be resolved : https://crmsrv.example.com/Organization/XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1 ---> System.ServiceModel.FaultException: An error occurred when verifying security for the message.
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) System.ServiceModel.Description.IMetadataExchange:Get (System.ServiceModel.Channels.Message)
at System.ServiceModel.Description.MetadataExchangeClient.GetMetadataInternal (System.ServiceModel.EndpointAddress address, MetadataExchangeClientMode mode) <0x417e5900 + 0x0026a> in
@ariskemper The problem may be related either to the CRM deployment or the network configuration.
Could you try to access to another CRM server from the same machine? For example a CRM online. This will discard problems with the Server configuration.
Also you can try to run the same DynamicsIntegration script from another PC in the same network. Also a test in a Windows PC may discard issues with Mono or the Ubuntu configuration.
Thanks,
I tried to connect and works on Windows machine which is in the same network and domain. In Ubuntu problem still exist even, if i used powerbroker (pbis) to join machine in domain.
i am getting the same error, running code on https://tonicdev.com/npm/dynamicsnode but when i hit link i get in error for example. http://abc.example.com/Organization/XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1, in my browser i get xml data properly.
@pradeep-mishra , I got the same error while connecting to online CRM 2016.
Fix for my problem. The reason it is browsable from browser and not through .net client is browser already has windows login credentials. But .net client doesn't take them until specified explicitly.
Added below section in config file and worked.
<system.net>
<defaultProxy useDefaultCredentials="true" >
</defaultProxy>
</system.net>
@avinashlanka Thanks for the info. Where did you add that config file?
@pradeep-mishra what OS are you connecting from?
@crisfervil , I was trying to create Organization proxy for online instance through my companies network (code written in console application - same code as above). When I tried to browse the URL from my browser - wsdl renders. Got error "Metadata contains a reference that cannot be resolved" while creating proxy.
To solve, Added useDefaultCredentials="true" in console application config.
@avinashlanka
@ariskemper
I have the same error when I run it on mono. Do you guys have any idea to fix it?
@hanpeic I'm afraid this project won't work in Mono, due to a couple of bugs not yet resolved and a few missing WPF libraries.
I have my hopes in .net Core to be able to run this in Ubuntu, but again, we still need to wait until the System.Xaml.dll is available in the platform.
Why System.Xaml.dll ? There's a dependency to this dll in one of the CRM SDK Assemblies (Microsoft.Xrm.Sdk.Workflow), and even though none of the DynamicsNode code references Workflows, this library is still required when a connection to the server is made.
What version of CRM are you trying to connect to? There's a Web Api endpoint available in CRM, that would be very simple to interact with using node. More info here: https://msdn.microsoft.com/en-us/library/mt593051.aspx
@crisfervil Thanks for you message. I try to ask them do they have other api.
Update Microsoft.Xrm.Sdk.dll
OR
Use this code above connection string
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;