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 (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:
At a high-level below is what the code does:
- 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
- POST https://login.live.com/ppsecure/DeviceAddCredential.srf
- Get the PUID from response
- Pass the device credentials
- POST https://login.live.com/****STS.srf (dynamically obtained)
- Get the device CiperData (BinaryDAToken)
- Pass the WLID username, password and device BinaryDAToken
- POST https://login.live.com/***STS.srf (dynamically obtained)
- Get the security tokens (2 CipherValues) & X509SubjectKeyIdentifier
- Do CRUD with the web service by passing X509SubjectKeyIdentifier, 2 CipherValues and the SOAP request (with data payload)
- POST https://yourorganization.api.crm.dynamics.com/XRMServices/2011/Organization.svc
- 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!