Using the MetadataService Web Service
[Applies to: Microsoft Dynamics CRM 4.0]
To use the MetadataService Web service you have to specify the URL and the organization name as shown in the following example. Notice that many security roles have metadata access disabled by default. If you have problems accessing the metadata Web service, check whether the security role has read access to Entity, Attribute, and Relationship. To do this, open the security role and then click the Customization tab. You might notice this problem occurs when you are deploying your custom code because the developer or tester will have access but the end user does not.
The following example shows you how to access the server by using the MetadataService Web service.
// Create an authentication token for your organization. MetadataSdk.CrmAuthenticationToken token = new MetadataSdk.CrmAuthenticationToken(); // Replace 'AdventureWorksCycle' with your Microsoft Dynamics CRM organization name. token.OrganizationName = "AdventureWorksCycle"; // Use Active Directory authentication. token.AuthenticationType = 0; // Set up the metadata service. MetadataService mdSevice = new MetadataService(); mdSevice.Credentials = System.Net.CredentialCache.DefaultCredentials; // Substitute the name of your Microsoft Dynamics CRM server. mdSevice.Url = "http://myservername/MSCRMServices/2007/MetadataService.asmx"; // Set the token. mdSevice.CrmAuthenticationTokenValue = token; mdSevice.UnsafeAuthenticatedConnectionSharing = true;
For an example that works with Microsoft Dynamics CRM Online, refer to the downloadable sample code in this folder: Sdk\Walkthroughs\Authentication\CS\Passport.
In This Section
Describes how to add the Web service to your program.
Explains the names that are used in the Metadata Web service.
Shows how to use the label class in the Metadata Web service.
© 2010 Microsoft Corporation. All rights reserved.