Click here to Skip to main content
Licence CPOL
First Posted 22 Oct 2007
Views 14,434
Downloads 18
Bookmarked 14 times

How to debug a CRM 3.0 callout efficiently

By | 9 Dec 2007 | Article
CRM 3.0 callout development.

Introduction

Have you ever had to develop a CRM 3.0 callout? If so, you know how time consuming and inefficient the debugging process can be.

This article will show you how to debug via Visual Studio, the way it was meant to be done.

Background

I had to find an alternative to debugging a CRM 3.0 callout, given that the business logic for one of my projects started getting unmanageable and errors where getting hard to find.

Using the code

This is as simple as it gets. Essentially, I am calling a Web Service at every callout method. Before calling the Web Service, I have to serialize the complex objects that CRM uses. I used a combination of a Web Service I wrote and the callout, to ease the development and debugging. Essentially, on every event, the callout executes a Web Service method that accepts the same parameters.

  1. Create a Web Service. Ideally, it should be hosted as a virtual directory within the CRM 3.0 website.
  2. Override a method in the callout file. For the purpose of this tutorial, I will use the PostCreate method.
  3. The PostCreate method accepts the following parameters:
    • Microsoft.Crm.Callout.CalloutUserContext userContext
    • Microsoft.Crm.Callout.CalloutEntityContext entityContext
    • string postImageEntityXml

    It is a real pain to transfer complex classes such as the userContext via a Web Service, so I decided to serialize each class using the xmlSerializer and transfer every parameter to my Web Service as a string.

    Before we continue, we will need the Web Service.

    The Web Service is as simple as it gets. You will need a WebMethod named PostCreate that accepts the same number of parameters. On this end, every parameter is a string.

  4. Deserialize the string objects back into their original type (I will show you the code later.)
  5. Compile the projects and add the Web Service to the callout.
  6. In each callout method, you will need to call the Web Serivce before the base method is called.

Download the file included in this article and you are ready to go.

Instructions for getting up and running

  1. Extract the zip to your system.
  2. Copy the webservice folder to your inetpub/wwwroot or alternatively wherever you want to host it.
  3. Copy the callout code into Visual Studio.
  4. Make the necessary configs such as setting the Web Service URL, currently set at http://localhost/CalloutWebservice/SimboliqWebservice.asmx.
  5. Set the Web Service URL for the CRM in the callout base.
  6. The actual running and debugging depends on your configuration. I develop on a Virtual PC 2007 image using Windows Server 2003 as the guest OS and Visual Studio 2003 installed on the VPC.

At anytime, please feel free to visit my blog: http://mymscrm3.blogspot.com/.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Oshri Cohen

Web Developer

Canada Canada

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionis it really necessary? Pinmemberdarksander2:35 30 Oct '07  
AnswerRe: is it really necessary? PinmemberOshri Cohen9:14 30 Oct '07  
GeneralRe: is it really necessary? Pinmemberdarksander21:06 30 Oct '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 9 Dec 2007
Article Copyright 2007 by Oshri Cohen
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid