Showing posts with label CRM Online. Show all posts
Showing posts with label CRM Online. Show all posts

Thursday, April 26, 2012

External config for CRM Online wsdl based proxy

The sample which comes with CRM SDK to connects to CRM Online services uses an extension method and a partial class to attach the appropriate federation tokens for authenticating the calls against live services. 
The extension method is given for any class which derives from ClientBase. The DiscoveryServiceClient and OrganizationServiceClient are the proxy classes which derive from ClientBase and ClientBase respectively. The limitation of deriving from ClientBase is that the WCF Configuration has to be read from app.config or web.config files. 
Sometimes there are limitations where you want to read these configurations from an external file e.g. if you are shipping an add-in to outlook you definitely don't want to ship outlook.exe.config file. 
.NET 4.5 adds the capabilities for reading the configuration from external file but if you are developing against .NET 4.0 or earlier versions you face an issue and the only way out is to use a Custom Channel Factory as described on http://www.mssoftwareconsulting.com/msswc/blog/post/Override-WCF-Client-Settings-From-Custom-Config-File.aspx 

And instantiate the Channel using the Custom Channel Factory. However this class doesn't have a method to configure federation and attach appropriate tokens to the channel to call the CRM Online service successfully. 
The attached sample provides an additional method in this class which can be used to attach proper tokens to the channel. 


The sample can be downloaded from here


Happy coding!!!


¬Abhishek

Friday, July 1, 2011

CRM Online :- Setting up an efficient developer environment for SilverLight resources

I've started working on a project where i am supposed to build a silverlight web resource for CRM Online and test it. The Web Resource will use CRM OData APIs to communicate with the CRM Online system and hence it can be tested only once it is hosted within an HTML page which is hosted in a CRM Online as a web Resource. 
Now here are the steps one needs to follow in order to debug this silverlight code..
1) Upload the xap file as a web resource in the CRM Online instance using the Web UI
2) Publish the xap file 
3) Navigate to the html file using the URL 
4) Attach the IE to visual studio and then debug the code by setting break points 


This makes the debugging and developing the applications very tedious since every build means that i have to upload the resource and do navigation as well... 
In order to make this process efficient here is the setup i have done on my machine 


1) Use Web Resource Upload Utility to upload the xap file on CRM Online instance. Now every time you build your solution all you need to do is to click a button to upload and publish the new xap file to CRM Online instance. 
2) In the web project you got created when you create a silverlight project add a new html page where onload of the body redirect the browser to the url where your html file is added. Here's how the code of html might look like...







Set this html page as the startup page when you debug the stuff...


And you are set... 
Now every time you change your code the debug process looks like the following
1) Build the silverlight project and use the web resource upload utility to upload the xap file 
2) Press F5 and the html page you've in your web project will redirect you to CRM Online where your xap is being hosted 


And you are set. I might work on a command line utility to build and publish the xap file on CRM Online instance if it becomes a lengthy project. But for a small POC kind of work this is much more efficient then the normal way one has to follow...


hope this helps 
cheers!
~Abhishek

CRM Online :- How to get the organization name

While working with CRM Online sometimes it is necessary to get the organization name to do some tasks (Like using a Web Resource Upload Utility)
Now in an on premise CRM system the organization name can be found from the URL or from the deployment manager. But there's no such flexibility in case of CRM Online. 
To get the organization unique name you need to go to 
Settings -> Customization -> Developer Resources and there you would find the name of the organization as you can see in the below screenshot. 


This is the organization name you can use to connect to your CRM Online instance with utilities such as Web Resource Upload Utility :)

NJoi!!!

~Abhishek