Updated 22nd March 2011: The sample has been modified to support CRM Online accounts in Europe & Asia. For more details regarding the fix, please see:http://blogs.msdn.com/b/girishr/archive/2011/03/22/crm-online-2011-web-services-soap-sample-now-ready-for-emea-amp-asia.aspx

Recently I have had a number of developers asking me about using CRM Online web services from within non.NET applications such as PHP or Flash web apps. Given my heads down approach on .NET these days I ended up putting together a pretty basic sample in C# that shows how to access CRM Online web services using SOAP messages only. This code sample retrieves data from CRM Online using pure SOAP calls only and no additional assemblies to illustrate the underlying SOAP interactions. Couple of ISV partners were able to successfully use this sample and port it over to PHP & Adobe ActionScript, so this stuff apparently works!

The soap messages were based on Fiddler (http://www.fiddler2.com) traffic capture of sample code from the CRM 2011 SDK (http://msdn.microsoft.com/en-us/library/gg309408.aspx).

You can download the sample code here:
http://code.msdn.microsoft.com/CRM-Online-2011-WebServices-14913a16

At a high-level below is what the code does:

  1. Pass in the device credentials and get a PUID. The device credentials is a randomly generated string that satisfies Live ID schema. You can generate one from this tool: Create CRM 2011 Beta Device
    1. POST https://login.live.com/ppsecure/DeviceAddCredential.srf
    2. Get the PUID from response
  2. Pass the device credentials
    1. POST https://login.live.com/liveidSTS.srf
    2. Get the device CiperData (BinaryDAToken)
  3. Pass the WLID username, password and device BinaryDAToken
    1. POST https://login.live.com/liveidSTS.srf
    2. Get the security tokens (2 CipherValues) & X509SubjectKeyIdentifier
  4. Do CRUD with the web service by passing X509SubjectKeyIdentifier, 2 CipherValues and the SOAP request (with data payload)
    1. POST https://yourorganization.api.crm.dynamics.com/XRMServices/2011/Organization.svc
    2. Get the result from the CRUD response and parse XML to get the data you need

 

BTW the new MSDN code gallery (beta) is pretty awesome with the ability to browse through the source code without downloading and extracting the zip file.
Pretty nice, huh!

image