Connecting to CRM Online 2011 Web Services using SOAP Requests Only

Updated 29th August 2012: The sample has been modified to support both the Microsoft online services environment (Office 365 style) authentication and the Microsoft account (formerly Windows Live ID) authentication. Once again many thanks to Ryan Lo from Marketo for providing the updated sample.

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 ( traffic capture of sample code from the CRM 2011 SDK (

You can download the sample code here:

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
    2. Get the PUID from response
  2. Pass the device credentials
    1. POST\*\*\*\*STS.srf (dynamically obtained) 
    2. Get the device CiperData (BinaryDAToken)
  3. Pass the WLID username, password and device BinaryDAToken
    1. POST***STS.srf (dynamically obtained)
    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
    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!