Creating CRM4 web service using proxy class

After my post earlier today, I got a question on how to create the proxy class for accessing a CRM4 installation. When I started my project for CRM import I was recommended to create a web service to implement access for against CRM4. I tended to use WCF to enhance my knowlegde on that techonlogy, but our CRM expert recommended standard web service.

Create CRM proxy class(es)

  • Login on the CRM4 server
  • Download Install the CRM4 SDK from
  • Go to <CRM4SDK>\microsoft.xrm\tools
  • Type the following command at the DOS prompt:
crmsvcutil /server:http://localhost/MyCompany
           /dataContextPrefix:CRM4 /out:Xrm.cs

MyCompany in the /server link, is the same as OrganisationName used for the CRM4 installation.

Now, we have the foundation for accessing CRM4 using LINQ.   I’m not going to describe how to create a web service, but here is some sted-by-step instructions at  But when you have created the foundation for the web service, you need to add the appropriate DLLs as references from the CRM4SDK in your solution. These DLLs are as follow:

  • Crm4Dsk\bin\microsoft.crm.sdk.dll
  • Crm4Dsk\bin\microsoft.crm.sdktypeproxy.dll
  • Crm4Sdk\bin\microsoft.crm.sdktypeproxy.xmlserializers.dll
  • Crm4Sdk\microsoft.xrm\bin\microsoft.xrm.client.dll
  • Crm4Sdk\microsoft.xrm\bin\microsoft.xrm.portal.dll
  • System.Data.Services.dll
  • System.Data.Services.Client.dll

In addition, I always add logging using Log4Net in my development project.

When this is done, you might be adding DataContract classes for the CRM4 objects that should be used to pass values for creating and updating CRM data. The only important thing is to make sure the data contract is serializable. Example:

    public class AccountContract
        public string AccountNumber { get; set; }
        public string Name { get; set; }

Now, you can use this contract to create account objects and pass them to you web service methods.

Happy coding…


One thought on “Creating CRM4 web service using proxy class

  1. I blog quite often and I seriously thank you for your information.
    Your article has truly peaked my interest. I’m going to bookmark your website and keep checking for new details about once per week. I opted in for your Feed as well.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s