How to do Windows Live Authentication for CRM Online in JAVA?


  • Hello,

    I want to access CRM Online web service through Java.
    For accessing the CRM online web service we need security token (Which we get after Passport/windows Live authentication).
    But I have no knowledge about what is the standard way to do windows live authentication.
    I tried some code samples posted in blogs but none worked.
    Please help on this.
    8 февраля 2010 г. 9:17


Все ответы

  • Hi:

    If you give some more details as to what you need to do I might be able to offer more input, but in the past I did this by creating the CRM Authentication code and data parsing in a .NET dll and then calling that code from Java. Are you writing a Java application or a web-based applet?

    8 февраля 2010 г. 17:34
  • Thanks John,

    It is a Java Application.Did you used JNI for calling .NET DLL from Java?

    Till now what I have tried is as follows:

    (1)Tried the samples provided in SDK to understand ho CRM Online works in .NET.
    (2)Retrieved SOAP Message and URL for passport authentication using HTTP Sniffer tool.
    (2)Now when I try to do same thing in Java using the retrieved SOAP message and URL it fails:
    Here is URL and SOAP message that I am using for passport authentication.
    <?xml version="1.0" encoding="UTF-8"?>
    <s:Envelope xmlns:s=""
    	xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:wsp=""
    	xmlns:wsa="" xmlns:wssc=""
    		<wsa:Action s:mustUnderstand="1"></wsa:Action>
    		<wsa:To s:mustUnderstand="1">HTTPS://</wsa:To>
    			<wsse:UsernameToken wsu:Id="user">
    			<wsu:Timestamp Id="Timestamp">
    		<wst:RequestSecurityToken Id="RST0">
    			<wsp:PolicyReference URI="MBI_SSL"></wsp:PolicyReference>

    The above request I tried through JAVA SOAP API as well as Apache HTTPClient.For SOAP API its throwing exception  "Incoming Message stream is null" and for HTTP Client its simply returning complete Sign in web page.

    Code snippet using Java SOAP API:
       try {
                SOAPMessage message;
                SOAPConnection conn;
                BufferedReader bif = new BufferedReader(new FileReader("passportRequest.xml"));
                String request = "";
                while (true) {
                    String ss = bif.readLine();
                    if (ss != null)
                        request = request + ss;
                // Create SoapMessage
                MessageFactory msgFactory = MessageFactory.newInstance();
                message = msgFactory.createMessage();
                SOAPPart soapPart = message.getSOAPPart();
                // Load the SOAP text into a stream source
                byte[] buffer = request.getBytes();
                ByteArrayInputStream stream = new ByteArrayInputStream(buffer);
                StreamSource source = new StreamSource(stream);
                // Set contents of message
                SOAPBody soapBody = message.getSOAPBody();
                conn = SOAPConnectionFactory.newInstance().createConnection();
                SOAPMessage response =, fURL);
                SOAPBody body = response.getSOAPBody();
            catch (SOAPException e) {
                System.out.println("SOAPException : " + e);
            catch (IOException e) {
                System.out.println("IOException : " + e);

    9 февраля 2010 г. 3:50
  • Hello, I am also interested in enabling CRM and SAML 2.0.  Is there updated information available on this thread?  Thank you!



    4 октября 2010 г. 17:55

    The blog posting above appears to completely dissect the interaction with Windows Live for authentication to CRM Online in raw SOAP calls.  Though the solution is programmed in C#, I suspect that it wouldn't be difficult to translate into JAVA.  There doesn't appear to be a necessity to use the .Net assembly for Live authentication which is included with the CRM SDK.

    Dave Berry - MVP Dynamics CRM - http:\\
    4 октября 2010 г. 18:08
  • Thank you!  This is extremely helpful!



    6 октября 2010 г. 3:39