The Microsoft Dynamics CRM Blog
News and views from the Microsoft Dynamics CRM Team

SilverCrmSoap: A CRM Soap Library for CRM 2011

SilverCrmSoap: A CRM Soap Library for CRM 2011

  • Comments 2

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

clip_image002

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

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

clip_image001[2]SilverCrmSoap.CrmSdk

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.

clip_image001[3]SilverCrmSoap.FetchXml

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

clip_image001[4]SilverCrmSoap.Helpers

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

clip_image004

XrmHelper

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

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 Xrm.Page.data.entity.attributes JScript Object.
  • SetEntityValue: Sets a value from the form using the Xrm.Page.data.entity.attributes JScript Object.
SoapHelper

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

Cheers,

Carlton Colter



  • Spectacular work!

  • My English is not good,I have a problem,when  "service.BeginExecute(request, new AsyncCallback(EntityList_ClickCallback), service)", there in a probelem is " request error. This may be due to trying to cross-domain access to services but not have the correct cross-domain policy, or policy does not apply to SOAP services. You may need to contact the owner of the service, to publish a cross-domain policy file and make sure the file is allowed to send SOAP-related HTTP headers. This error may also be due to the use of the Web service proxy in the internal properties of the type without using InternalsVisibleToAttribute" do you kown this problem?

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post