Microsoft Dynamics 365 Blog

SilverCrmSoap is a library built using the methods in Walkthrough: Use the SOAP Endpoint for Web Resources with Silverlight. The SilverCrmSoap library simplifies SOAP Silverlight development for CRM 2011 by providing a class that does a lot of the heavy lifting right out of the box.

clip_image001Why use SilverCrmSoap?

If you are using the SOAP End Point, then the library will help simplify your project by removing the complexities of connecting to the SOAP End Point in Silverlight while providing additional tools to assist with your Silverlight project.  In the end, it really boils down to where do you use SOAP instead of REST?  You use SOAP when:

  • You need to use late binding to create a dynamic Silverlight application that works with any (or multiple) entities.
  • You need to execute a message.
  • You need to assign records.
  • You need to retrieve metadata.

There are benefits to using the REST endpoint too, and being able to quickly leverage both end points in a project can be extremely helpful.  You should use the REST End Point when:

  • You need to early bind to objects.
  • You want to leverage LINQ with the early bound objects.
  • You want compile time type support and IntelliSense.

You can find more information on the SOAP and REST End Points in the MSDN Article: Use Web Service Data in Web Resources (REST and SOAP Endpoint).

clip_image001[1]Using SilverCrmSoap

The SilverCrmSoap library is built to be added as a compiled DLL reference in a Silverlight projects.  It facilitates making calls to CRM when used in a Silverlight Web-Resource. 

Inside your Silverlight application solution in Visual Studio, add a reference to the compiled SilverCrmSoap.dll


Once referenced, there are three namespaces that assist with Silverlight development for CRM:

  • SilverCrmSoap.CrmSdk
  • SilverCrmSoap.FetchXml
  • SilverCrmSoap.Helpers


Built following the steps in Walkthrough: Use the SOAP Endpoint for Web Resources with Silverlight, this namespace provides access to the SOAP Endpoint.  The SilverCrmSoap.CrmSdk also contains some examples for extending the base Entity class.  In the SilverCrmSoap project a UserOwnedEntitiy class has been added that extends the Entity class and raises the appropriate event when a field is changed.  By default the SOAP Entity object only raises a property changed event if the Attributes object itself is changed.  In addition to the UserOwnedEntity class which specifies the default fields for user owned entities, an Annotation class has been added that inherits from the UserOwnedEntity, adding the specific fields for notes.  This type of extension becomes important when you are attempting to facilitate data-binding.


The FetchXml namespace provides a set of classes built according to the FetchXml schema to allow deserialization of FetchXml to support the modifying parameters through code, i.e. objectifying FetchXml.  You will want to do this because a query expression does not return column values from another entity, and yet the reason why QueryExpressions are used so widely is because of their ability to easily be modified through code.  By de-serializing the FetchXml query string, you will be able to edit it’s values using objects, then serialize it to use in your queries


The SilverCrmSoap Library contains 3 helpers, the Xrmhelper, the FormHelper, and the SoapHelper.



The XrmHelper provides on-demand access to the JScript objects that are commonly used such as the Xrm.Page, context, etc.  It is also able to determine if the control was loaded as a web-resource on a form or if it was loaded outside a form.  When using this helper, it is important to either put the web-resource on the form or put it on an html page that provides access to the GlobalContext.


FormHelper takes the XrmHelper and provides a couple of additional quick access methods that utilize the JScript objects XrmHelper provides:

  • GetUserPrivilege: Get the privileges for an attribute and determines if the user can read, update, or create.
  • GetEntityValue: Gets a value from the form using the JScript Object.
  • SetEntityValue: Sets a value from the form using the JScript Object.

The SoapHelper was built to leverage the walkthrough for interfacing the SOAP End Point and provide a set of methods to launch the proper asynchronous call, simplifying access.  One of the great things about these helpers is that you don’t need to specify the URL to use them.  They leverage the context to correctly set the service URL.  The SoapHelper provides a way to quickly connect to the SOAP End Point and a set of methods to jumpstart the begin statements of asynchronous SOAP calls:

  • BeginAssociate
  • BeginCreate
  • BeginUpdate
  • BeginDelete
  • BeginDisassociate
  • BeginExecute
  • BeginExecuteFetch
  • BeginExecuteRetrieveAllEntities
  • BeginExecuteRetrieveEntity


Carlton Colter

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!