Wednesday, 23 November 2016

CRM Web Services

                                          MS CRM Web Services
The Microsoft Dynamics CRM web services allow external resources to interact with CRM data and with the metadata that defines the specific CRM instance to which you’re connecting.
There are two web services exposed by CRM:
IOrganizationServiceThis is the primary web service used to access (CRUD operations) customer, sales, marketing, and service data; in addition, it exposes metadata that defines the specific “structure” of the CRM organization that you’re accessing.
IDiscoveryThis web service allows a developer to examine the possibly multiple organizations that are hosted within a single instance of CRM (multi-tenancy) to determine which is the proper organization and endpoints to use for data access.
Discovery Service is a web service which lets us determine the organizations that a particular user belongs to. It provides information such as the organisation friendly name, URL endpoints, unique id, version, unique name, URL name, and the current state
For Microsoft Dynamics 365 (online & on-premises) installations, server and organization allocation may change as part of datacenter management and load balancing. Therefore, the IDiscoveryService Web service provides a way to discover which Microsoft Dynamics 365 server is serving your organization at a given time.
The following table lists the Web service URLs for the worldwide Microsoft Dynamics 365 (online) data centers.
Location
Discovery Web service URL
Identity Provider
North America
https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft account
https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
North America 2
https://disco.crm9.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Europe, Middle East and Africa (EMEA)
https://dev.crm4.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft account
https://disco.crm4.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Asia Pacific Area (APAC)
https://dev.crm5.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft account
https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Oceania
https://disco.crm6.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Japan (JPN)
https://disco.crm7.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
South America
https://disco.crm2.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
India (IND)
https://disco.crm8.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Canada
https://disco.crm3.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
For an Internet-facing deployment (IFD) installation, the Web service URL has the following form:
https://dev.< hostname[:port]>/XRMServices/2011/Discovery.svc
For an on-premises installation, the web service URL has the following form:
http[s]://< hostname[:port]>/XRMServices/2011/Discovery.svc
Consult the Developer Resources page in the Microsoft Dynamics 365 Web application for the correct URL of your installation.
To use the IDiscoveryService Web service, add a reference to the Microsoft.Xrm.Sdk.dll assembly to your Microsoft Visual Studio project, and then add a using or imports statement to access the Microsoft.Xrm.Sdk.Discovery namespace. Alternatively, you can add the service references for the URLs described previously to your project.
The Microsoft Dynamics CRM web services are primarily used for building portals (allowing non-CRM users to interact with CRM data) or for allowing external applications to push or pull CRM data or for other external applications to integrate CRM data with other systems.
The primary usage of the iOrganizationService is to execute CRUD operations against CRM data; the most widely used methods of the web service, thus, are CreateRetrieveUpdate and Delete. However, there is also an Execute method which provides a Request/Response system for executing platform “message” like running a workflow, assigning records to queues, deactivating records, or a wide variety of other platform operations.
Other usage of CRM web services include:
  • Mobile applications
  • Portal Development
  • Custom CRM User Interface Development
  • Data Migration
  • Data Integrations
examples
Uri discoUri = new Uri("http://mycrmserver/XrmServices/2011/Discovery.svc");NetworkCredential nc = new NetworkCredential{    Domain = "mycrmserver",    UserName = "roshan",    Password = "password"}; 
ClientCredentials cc = new ClientCredentials();cc.Windows.ClientCredential = nc; 
DiscoveryServiceProxy proxy = new DiscoveryServiceProxy(discoUri, null, cc, null);proxy.Authenticate(); 
RetrieveOrganizationsRequest request = new RetrieveOrganizationsRequest();RetrieveOrganizationsResponse response = (RetrieveOrganizationsResponse)proxy.Execute(request); 
foreach (OrganizationDetail d in response.Details){    Console.WriteLine(d.FriendlyName);} 

No comments:

Post a Comment