Introduction
============
    The sample code shows how to use Java client to talk to HPC V3 SOA service. 
    It is based on Apache CXF 2.1.4.

Prerequisites
=============
    1) JDK 1.6.0.18
       Please follow JDK's instructions on how to install.
       
    2) CXF 2.1.4 (Warning: other versions of CXF may not work.)
       Installation: download apache-cxf-2.1.4.zip to c:\Java directory. unzip it there.
       
    3) Windows SDK or Visual Studio 2008 (for MakeCert.exe, SvcUtil.exe)
       http://msdn.microsoft.com/en-us/windows/bb980924.aspx
       
How to setup the system
=======================
    1) On client machine, download and install all "Prerequisites".
       Get MakeCert.exe, SvcUtil.exe from the SDK.

    2) On a cluster, install HPC Pack. Make sure you have at least 1 broker node.Be default, the headnode will work as both broker node and compute node so it should be fine.

    3) On head node, edit %CCP_HOME%Bin\HpcSession.exe.config.
       Replace "localhost:443" with your <headnode>:443.

       For example, assume your headnode is called "HeadNode1"
       
        <services>
            <service name="Microsoft.Hpc.Scheduler.Session.Internal.SessionLauncher.SessionLauncher" behaviorConfiguration="EnableMetadata">
                <host>
                    <baseAddresses>
                        <add baseAddress="https://HeadNode1:443/SessionLauncher"/>
                    </baseAddresses>
                </host>
                ...
        </service>
        
    4) On broker node, edit %CCP_HOME%Bin\HpcBroker.exe.config. 
       Replace "localhost:443" with your <brokernode>:443.

       For example, assume your brokernode is called "BrokerNode1"
       
        <services>
            <service name="Microsoft.Hpc.Scheduler.Session.Internal.BrokerLauncher.BrokerLauncher" behaviorConfiguration="EnableMetadata">
                <host>
                    <baseAddresses>
                        <add baseAddress="https://BrokerNode1:443/BrokerLauncher"/>
                    </baseAddresses>
                </host>            
                ...
        </service>
        
    5) On both head node and broker node, setup certificate. (NOTE: if your broker node is your head node, only do it for once.)
          a) make sure makecert.exe is in your PATH.

          b) Create a self-signed certificate. Run the following command in elevated console:
               createcert.cmd <nodename>
            
          c) Install the certificate.
             In PowerShell, run as an admin user,
             - Set-ExecutionPolicy Unrestricted
             - installcert.ps1 install
             - select the new certificate just created above. It's the one named "CN=<nodename>". Normally it should be the last one.
         
    6) On headnode, restart HpcSession service.
       On brokernode, restart HpcBroker service.

    7) On java client machine, verify that the services are running via https from internet browser: 
            https://<headnode>/sessionlauncher
            https://<brokernode>/brokerlauncher

       Note: you may get certificate error. If so, click "Continue to this website".
       Expected: you should be able to see a page with the service info and some sample code.

    8) On java client machine, set up SSL trust between Java client and Headnode/BrokerNode.
         - download java code: http://blogs.sun.com/andreas/entry/no_more_unable_to_find
            http://blogs.sun.com/andreas/resource/InstallCert.java

            
         - Create the environment variable JAVA_HOME and set it to the Java installation path.

                    - "%JAVA_HOME%\bin\javac.exe" InstallCert.java

         a) Create head node certificate.
            - "%JAVA_HOME%\bin\java.exe" InstallCert <HeadNode>
            - The above should create a file called "jssecacerts"
            - copy jssecacerts to overwrite %JAVA_HOME%\jre\lib\security\cacerts (NOTE: You need administrate privilege on Vista/7)

         b) Create broker node certificate.
            - "%JAVA_HOME%\bin\java.exe" InstallCert <BrokerNode>
            - The above should create a file called "jssecacerts"
            - copy jssecacerts to overwrite %JAVA_HOME%\jre\lib\security\cacerts
            
            This is expected to overwrite the cacerts created in a).

    9) Verify that your certificate are in cacerts.
         - cd %JAVA_HOME%\jre\lib\security
         - "%JAVA_HOME%\bin\keytool.exe" -list -keystore cacerts
         	Enter keystore password:  changeit
         - Validate: the headnode and brokernode certificate should be listed by keytool.
         

How to run the tests
====================
    1. cd SessionAPI. build Microsoft.Hpc.Scheduler.jar.
    2. cd CcpEchoSvc. build CcpEchoSvc.jar.
    3. copy the above 2 jars to directories HelloWorld and BasicTests.
    4. cd HelloWorld. run tests.
    5. cd BasicTests. run tests.
