Search |
||
Java and .NET Interoperability - Let's just do itPosted by rpatel on February 12, 2007 at 10:53 AM PST
With the release of Web Services Interoperability Toolkit (WSIT), many of us have been asking one basic question - how to go about making the Java and .NET endpoints work? How to prototype this interoperability? In this blog, I am outlining the steps to do just that. I will show you how to establish the most basic interoperability between Java and .NET platforms using Web services. Step 1 - Install the following softwares on your system 1) WSIT Milestone 2 Release (wsit.dev.java.net) 2) Glassfish v2 build 18 (https://glassfish.dev.java.net/downloads/v2-b15.html) 3) NetBeans 5.5 IDE (http://www.netbeans.info/downloads/index.php?) 4) WSIT NetBeans Module v1.41 (Flash based tutorial of downloading and installing this NetBeans module is 5) Install .NET Framework 3.0 (http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857- 6) Install .NET SDK 3.0 (http://www.microsoft.com/downloads/details.aspx?FamilyId=C2B1E300-F358-4523-B479-F53D234CDCCF&displaylang=en) (**) Step 2 - Start the NetBeans 5.5 IDE Step 3 - Deploy Java Web service endpoint Follow this Flash tutorial to deploy a simple Java Web service, NewWebService. You should make two changes to your Web service for the purpose of showcasing interoperability with .NET:- 1) Even though the tutorial instructs to turn Reliable Messaging on, for .NET interoperability purposes, don't turn it on for simplicity sake. We will test interop between the two platforms in this demo for just MTOM functionality. 2) The July CTP versions of .NET Framework 3.0 and .NET SDK 3.0 misbehaves and sends an invalid SOAP action string to the Java Web service endpoint. See this excellent blog entry from Arun Gupta, one of our senior engineers involved with WSIT and JAX-WS, where he talks about this issue. For now the workaround is to specify explicit SOAPAction values for operations at the service endpoint. Therefore, your NewWebService Java implementation class, NewWebService.java, should look like this: -------- @WebService() @WebMethod(action="operation") Notice that here we specify SOAP action with the help of action attribute of @WebMethod annotation applicable to the Web service method. Step 4 - Test the Java Web service endpoint Now test whether NewWebService has been deployed properly by typing the following URL in your browser - http://localhost:8080/WebApplication1/NewWebService?WSDL Step 5 - Generate .NET C# client artifacts Now that our Java Web service endpoint is up and running, let us visit the .NET world for a moment to create a very simple C# client application. First, open a command prompt window, and type the following command to create C# client artifacts needed to communicate with our Web service. Notice that svcutil uses MEX (Metadata Exchange) protocol to retrieve the Web service's information. Step 6 - Write the C# Console application client for Java Web service Write the following C# console application (and save it as NewWebServiceProxyTest.cs) to act as a client to our Java Web service endpoint: -------- class NewWebServiceProxyTest { // Create an instance of the Web service class. // Call the Web service method. // Output the results to the console. Step 7 - Compile the C# console application csc /t:exe /r:c:\windows\microsoft.net\framework\v3.0\window~1\System.ServiceModel.dll,c:\windows\microsoft.net\framew In the above command, window~1 folder refers to the "Windows Communication Foundation" folder under the .NET framework installation folder. Step 8 - Run the console application Run the client C# console application from the command prompt, and you should see an output as below: c:\> NewWebServiceProxyTest.exe The result returned by Web service operation is: Hello there. Hopefully, this demo works for you. As I gain more knowledge about making the higher layers of the WS stack interoperate, I'd blog more on the subject later. »
Related Topics >>
Java Enterprise Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|