Friday, October 19, 2007

How to debug a Callout efficiently.

Debugging a Callout must be the single most tedious task that i have ever had to do while developing for CRM 3.0.

The need to continuously restart IIS and the associated services is very time consuming.

I used a combination of a webservice i wrote and the callout to ease the development and debugging.
Essentially, on every event the callout executes a webservice method that accepts the same parameters.

1) Create a webservice, ideally it shoudl 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 webservice, so i decided to serialize each class using the xmlSerializer and transfer every parameter to my webserice as a string.

Before we continue we will need the webservice.

The webservice i as simple as it gets, you will need a WebMethod named PostCreate that accepts the same number of paremeters, just 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 webservice to the callout.

6) In each Callout method you will need to call the webserivce before the base method is called.

I will post a generic callout class shortly so that all you need to do is add it to your project and start working.

*** If you are worried about performance, don't be after the first callt he webservice get's cached and every subsequent call has little performance penalty.

Here is the link to the Complete project:

Simboliq Callout project with webservice

Oshri Cohen

Labels: , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home