by Peter Taylor
13. March 2008 16:07
One problem that I have recently come across when attempting to create a custom windows application to interface with Microsoft CRM 4.0 is that some of the classes outlined in the SDK appeared to be missing from the CRM web services, specifically from the CrmService, when I went and added these services to my Visual Studio project as web references.
When I then subsequently tried to work through some of the examples outlined in the SDK, this issue would cause errors which would halt the build process, for example:
The name 'EntityName' does not exist in the current context
The type or namespace 'BusinessEntityCollection' could not be found
As far as I can see, when this problem occurs, it is due to the fact that the CRM server is not generating a complete WSDL file. The CRM server is only returning the base WSDL classes and not those specifically rendered by CRM.
I eventually solved this issue by changing the URL that my CrmService web reference pointed to. I had been using the URL below to reference the CrmService web reference, which was in the same format as the URL used to access the CRM installation:
http://servername/organisation/mscrmservices/2007/crmservice.asmx
However, when I changed this reference to the URL below, the missing classes were subsequently returned, along with new enumerations for my CRM customizations:
http://servername/mscrmservices/2007/crmservicewsdl.aspx?uniquename=organisation
For reference, the CrmDiscoverService and the MetadataService URLs I used were as follows:
http://servername/mscrmservices/2007/ad/crmdiscoveryservice.asmx
http://servername/mscrmservices/2007/metadataservice.asmx
Alternatively, you can also always access the CrmService WSDL file directly through the Settings > Customization > Download Web Service Description Files area of the CRM interface; then save this file somewhere and use the saved file as the source for you web reference. However, if you do use this method, you will need to remember to update the saved file whenever you make further customizations to your CRM installation.