Code to configure CRM API Service

 

ClientCredentials credentials =

 

 

new ClientCredentials();

 

credentials.Windows.ClientCredential =

 

 

new System.Net.NetworkCredential(“username”,“password”,“domain”);

 

 

Uri

 

 

 

 

organizationUri = newUri(“http://servername:port/orgname/XRMServices/2011/Organization.svc”);

 

 

Uri

 

 

 

 

homeRealmUri = null;

 

OrganizationServiceProxy orgService =

 

 

new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);

 

IOrganizationService _service = (IOrganizationService)orgService;

 

try

 

 

 

 

{

 

Entity contact =

 

 

new Entity(“contact”);

 

contact[

 

 

"lastname"] = “my last name”;

 

_service.Create(contact);

 

}

 

catch

 

 

 

 

(Exception ex){

 

MessageBox.Show(ex.Message);

 

}

 

In

 

 

case of early-bound, don’t forget to add the following line of code

 

 

 

OrganizationServiceProxy _serviceProxy =

 

 

new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);


// This statement is required to enable early-bound type support.

 

_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(

 

 

new ProxyTypesBehavior());

This entry was posted in MS Dynamic CRM 2011. Bookmark the permalink.

Comments are closed.