Reputation: 1088
From my ASP.NET web site or Console program I want to read/update CRM Account/Contact data.
I have set up my Service Reference by getting the "/Organization.svc" WSDL and wrote the below code (console program):
using (var client = new OrganizationServiceClient()) {
//client.Open();
var query = new QueryExpression();
query.EntityName = "AccountSet";
query.ColumnSet = new ColumnSet {AllColumns = true};
var coll = client.RetrieveMultiple(query);
Console.WriteLine("Retrieved {0} entities", coll.Entities.Count());
foreach (var item in coll.Entities) {
Console.WriteLine("Account: " + item);
}
}
However I get a: "An error occured when verifying security for the message.". I think this is due to not authenticating. However I could not find an authentication method from the WSDL generated code. Any help on fixing this without manually writing SOAP messages?
Also I need to know which auth server to log in / good tutorial for this process.
Thanks.
*Edit: the CRM is a free Microsoft trial site
Upvotes: 1
Views: 1671
Reputation: 7234
You do not connect to CRM directly using the WSDL. Technically you can but you would have to program extensively to make it work. Instead, you should use the functionality that Microsoft provides in the Dynamics SDK.
You'll need the DLL's in the \SDK\Bin\ folder to successfully create a connection from your .NET application to your CRM Online instance.
You can download the SDK from http://www.microsoft.com/en-us/download/details.aspx?id=40321
Within the SDK read the section called Sample: Simplified Connection Quick Start using Microsoft Dynamics CRM. The code in SDK\SampleCode\CS\QuickStart\SimplifiedConnection.cs
get you started with a working connection to Dynamics CRM.
Let us know if you need more help.
Upvotes: 2