Access .NET from Macromedia Coldfusion MX 6.1 Using J-Integra® for .NET

Java/J2EE .NET Interoperability Products Page

This example demonstrates how to access .NET from Macromedia Coldfusion MX 6.1. J-Integra® for .NET is a Java interoperability component that bridges Java and Microsoft .NET. It provides bi-directional access of Java objects and .NET components.

Synopsis

Use this example as a guideline to show you how to access a Client Activated Object (CAO) hosted in Microsoft Internet Information Services (IIS), and from Macromedia ColdFusion MX 6.1 using J-Integra® for .NET. The CAO will be accessed via a Coldfusion Markup Language (CFML) page.

The Steps to Follow will show you how to deploy J-Integra® for .NET correctly for this example. Refer to the diagram below for an overview of the scenario:

Access .NET from Macromedia Coldfusion MX 6.1 Using J-Integra® for .NET

Note: $USER_INSTALL_DIR$ is the directory where J-Integra® for .NET has been installed. If this location contains whitespace characters (e.g. C:\Program Files\...), you may need to include it within "" when referencing it at the command-line. CFHOME is the directory where Coldfusion MX 6.1 is installed.

Prerequisites

  1. A platform with Microsoft Visual Studio .NET 2003 (7.1.3088 or higher) installed, or at least the .NET Framework 1.0.3705 or higher. This will be known throughout the example as the .NET platform.

  2. A platform with Coldfusion MX 6.1 and J-Integra® for .NET 1.5.1265 (or higher) installed. This will be known throughout the example as the Java platform.

  3. A version of JDK installed on the Java platform, and the bin directory included in the path. This required for the jar utility and to compile the Java proxies.

  4. Verify that GenService is installed correctly on the .NET platform.

  5. IIS 5.0 (or higher) on the .NET platform.

Steps to Follow

  1. Compile the .NET Assembly

  2. Run GenJava and Compile the Proxies

  3. Deploy the .NET Assembly in IIS

  4. Run Janetor to Configure J-Integra® for .NET

  5. Configure Coldfusion MX 6.1

  6. Deploy the CFML page

  7. Access the CFML page

Compile the .NET Assembly

Perform this step on the .NET platform.

In this step, you will need to compile the .NET code.

  1. Load csharp_server.sln located in $USER_INSTALL_DIR$\examples\coldfusion_iis\csharp_server with Visual Studio .NET 2003. Press F5 to build. If successful, this should build a .NET Assembly csharp_server.dll in the bin directory.

    Note: If you happen to have an older version of Visual Studio .NET, it is still possible to compile the .NET code, but you will not be able to open the solution file. See build.bat in $USER_INSTALL_DIR$\examples\coldfusion_iis\csharp_server.

Run GenJava and Compile the Proxies

Perform this step on the Java platform.

In this step, you will use the GenJava tool to generate Java proxies from the .NET Assembly.

Note: GenJava saves configuration details to an XML file. For your convenience, the settings described below have already been saved to the file genjava.xml in the directory $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client. If you'd prefer not to manually enter the settings as instructed below, simply copy this file over to $USER_INSTALL_DIR$ before starting GenJava.
  1. Windows

    Launch GenJava from the Start Menu.

    Command-Line

    Change directory to $USER_INSTALL_DIR$ and then enter:

    java -jar lib\genjava.jar
    	
  2. The first screen of GenJava prompts for the location of the .NET assembly along with the output directory where the Java proxies will go. They should be (respectively):

    - $USER_INSTALL_DIR$\examples\coldfusion_iis\csharp_server\bin\csharp_server.dll
    - $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client

    Using GenJava set source assembly and output directory for Java proxies

    Move on to the next step by clicking Next.

  3. You should see a message that the proxy generation was successful. Click Finish to exit GenJava.

    GenJava generates Java proxies successfully

  4. To compile the Java proxies, at the command-line, change directory to $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client and enter:

    javac -classpath $USER_INSTALL_DIR$\lib\janet.jar;. csharp_server\*.java
    	
  5. Create a JAR file to be later added in the CLASSPATH of Coldfusion MX 6.1. At the command-line, change directory to $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client and enter:

    jar cvf proxies.jar csharp_server\*.class
    	

Deploy the .NET Assembly in IIS

Perform this step on the .NET platform.

In this step, you will need to configure and deploy the .NET Assembly in IIS so it can respond to HTTP requests.

Along with Java proxies, GenJava generates .NET configuration files to be used as templates - one for the HTTP channel (web.config) and one for the TCP channel (remoting_tcp.config). As the .NET Assembly is being hosted by IIS, .NET will use web.config. You can find this in the same directory that the proxies were generated in.

  1. Modify web.config to look like:

    <configuration>
      <system.runtime.remoting>
        <application>
          <service>
            <activated type="csharp_server.JanetExample, csharp_server"/>
          </service>
          <channels>
            <channel ref="http">
              <serverProviders>
                <formatter ref="binary" typeFilterLevel="Full"/>
              </serverProviders>
            </channel>
          </channels>
        </application>
      </system.runtime.remoting>
    </configuration>
    	
    Note: If you are using a version of .NET Framework lower than 1.1 (1.0.3705), you will need to remove the <channels> tag and everything in between it. .NET Framework 1.1 introduced new secure serialization - details can be found here.
  2. Go to Start > Programs > Administrative Tools > Internet Services Manager.

  3. Right-click on the Default Web Site node and create a new virtual directory. In the Alias field, enter csharp_server.

  4. Browse to and select $USER_INSTALL_DIR$\examples\coldfusion_iis\csharp_server as the directory.

  5. Make sure that the Default Web Site is started.

Run Janetor to Configure J-Integra® for .NET

Perform this step on the Java platform.

In this step, you will need to configure J-Integra® for .NET to act as a client to access the CAO in the .NET Assembly. This is done through the Janetor tool.

  1. Windows

    Launch Janetor from the Start Menu.

    Command-Line
    java -jar $USER_INSTALL_DIR$\lib\janetor.jar
    	
  2. Select File - Open and open janet.xml located in $USER_INSTALL_DIR$\coldfusion_iis\java_client.

  3. Install your J-Integra® for .NET product license. See Installing the J-Integra® for .NET license for further information.

  4. Select default under Remote Objects. Here you see that J-Integra® for .NET is configured as a client to access a CAO at the given URI, using HTTP binary. The URI field is determined by the address of the IIS machine along with the virtual directory name chosen.

    Using Janetor configuration tool setup remote objects

  5. Before you exit Janetor, save the configuration by going to File - Save.

  6. At the command-line, change directory to $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client and enter:

    jar cvf license.jar janet.xml
    	

    This will create a JAR file which you'll include in the CLASSPATH of Coldfusion MX 6.1.

Configure Coldfusion MX 6.1

Perform this step on the Java platform.

In this step, you'll configure Coldfusion MX 6.1 to use J-Integra® for .NET.

  1. Start Coldfusion MX 6.1 (in Windows Services) and launch the Administrator Console.

  2. Under SERVER SETTINGS on the left, click on the Java and JVM link. For the Class Path field, enter the following components:

    - $USER_INSTALL_DIR$\lib\janet.jar
    - $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client\proxies.jar
    - $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client\license.jar

    Make sure to separate the components with a comma. See screenshot below:

    Configurate JVM in ColdFusion
  3. Click Submit Changes and restart Coldfusion MX 6.1.

Deploy the CFML page

Perform this step on the Java platform.

In this step, you will deploy the CFML page so it can be made accessible via the web server.

  1. Copy $USER_INSTALL_DIR$\examples\coldfusion_iis\java_client\janetexample.cfm to CFHOME\wwwroot

Access the CFML page

Perform this step on any platform that has Internet/Intranet access to the Java platform.

In this final step, you will access the CFML page to view the results.

  1. Launch a browser and enter the following URL:

    http://[Java platform]:8500/janetexample.cfm
    	
  2. You should see the following HTML output:

    Access .NET from Macromedia Coldfusion MX 6.1 Using J-Integra® for .NET

© 2007 Intrinsyc Software International, Inc. All rights reserved. Legal