CRM2011 – using IOrganizationService

In this post will be a simple way to use IOrganizationService:

 
Uri organizationUrl = new Uri("http://crm2011server/organizationname/XRMServices/2011/Organization.svc"); 
ClientCredentials credentials = new ClientCredentials(); 
// set default credentials for OrganizationService 
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials; 
// or credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; 
OrganizationServiceProxy organizationProxy= new OrganizationServiceProxy(organizationUri, null, credentials, null); 
IOrganizationService _service = (IOrganizationService)organizationProxy; 
try { 
   Entity case= new Entity("incident"); 
   case["name"] = "Test Case"; 
   _service.Create(case);
 } 
catch (Exception ex) 
{ 
   MessageBox.Show(ex.Message); 
} 
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());

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...