Ok, so here it is (download); I finally had the chance to finish this sample and put it in a form that others can learn from. Various folks both from the Silverlight team and the CRM team were involved in the process of finding ways to make it work (not listing their names here to keep their privacy) so thank you for that. The sample is extremely simple and is just meant to illustrate how to call the CRM service from within Silverlight 2 using the proxy that Silverlight generates. The two key pieces of the sample are:
· A method to wire up the CRM service: It has special logic that injects the CRM authentication token so that CRM can effectively process the calls (see my previous post for a bit more background).
· Usage of DynamicEntity when retrieving data from CRM.
Remember, the sample is provided “AS IS”; I bet there are many others out there that have come up with other patterns/helper-methods to achieve similar results.
I realized that I didn’t include explicit instruction on how to run this sample (I always assume that my audience is geek enough to understand everything I ramble he he) so here they are:
· Visual Studio 2008 + Silverlight SDK + Silverlight Tools for Visual Studio 2008
· Remember that in order for Silverlight to be able to call a web service the root of the server hosting the service must contain a clientaccesspolicy.xml (or equivalent) file stating that the server allows clients to issue calls to it. The project includes a sample clientaccesspolicy.xml that you can drop in the <crmwebroot> of your server. For more information about these security measures refer to the Silverlight documentation.
1. Make sure to drop the policy file (clientaccesspolicy.xml) under the Web root of your CRM server.
2. On page.xaml.cs change the values of the global variables to point to your server:
3. Open the project, compile it and run it J
a. If you have troubles compiling/running the project make sure you don’t have namespace conflicts (check this post )
4. If you want to host the sample outside of VS well, you will need to setup your own IIS website and/or put your files under the \ISV\[yoursubfolder] folder (check documentation on the CRM SDK)