Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Web Services » Web Services for .NET and J2EE Interoperability

Web Services for .NET and J2EE Interoperability

Web services technologies are designed to support the interoperability between many different application development platforms that exist today. This article is focused on the fundamentals of .NET and Java interoperability using Web services technologies.

Total page views :  23277
Total downloads : 
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Become a Sponsor


MindCracker Survey

Introduction

To develop distributed systems, Component based Programming is widely accepted. So far number of technologies has emerged to help building distributed systems within the enterprise. Most common Technologies are:

  • Distributed Component Object Model (DCOM)
  • Common Object Request Broker Architecture (CORBA)
  • Remote Method Invocation (RMI)

But in general, the concept of distributed computing stays within the boundaries of the organization as a whole. This is largely due to the ports and protocols to which these organizations are bound. For security reason, many developers and architects are restricted to using only ports 80 and 443 - the ports for HTTP and HTTPS. Even after various attempts, unfortunately for various reasons, no platform fully convinced enterprise architects to run a distributed architecture across the internet.

Interoperability is the ability for different applications to work together, even though they are running on different operating systems, on different hardware architectures, and using different application infrastructure. Programmable web sites that directly link organizations, application, and services would better meet their business needs. This direct linking of applications can be done easily using Web Services and Interoperability is one of the great promises made by the Web services architecture.

Web services is a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. And they must address these three key issues to be standardized:

  • Internet Standards
    HTTP and HTTPS must be the initial underlying protocols for Web services to succeed but the technology should be flexible enough to allow any transport protocol to be used.
  • Type definitions
    Data types that were exposed by Web services must use strongly typed XML.
  • Multiple language, platform and vendor support
    Web services must not be tied to a particular platform, language or vendor.

The Five components that make up the technical definition of a Web services are:

  1. Transport (HTTP)
    Currently, generally accepted transport protocol is HTTP (with HTTPS for secure connections). However, this doesn't mean that Web Services are tied to HTTP. They can also run on SMTP, SPX, NetBEUI and even on a custom sockets implementation.
  2. Encoding (XML)
    Regardless of the transport protocol used to carry it, the message must be correctly formatted as a valid XML document.
  3. Standard Structure (SOAP)
    XML defines how the message is encoded but doesn't dictate the structure or format of the document. SOAP is a three part definition that specifies an XML structure for the framework of a message known as SOAP envelope:
    • The data types that are defined
    • A convention for representing RPCs and
    • The data returned from them.
  4. Description (WSDL)
    WSDL completely describes the components being exposed and gives the name, data types (using XML Schema Definition), methods and parameters required to call them.
  5. Discovery (UDDI)
    Universal Description Discovery and Integration provides the exact URL of that particular Web Service.

The strongest reasons why we opted Web services for interoperability are:

  • Application to application communication across the internet
    XML Web Services provide standard defined interfaces called contracts that described the services that they provide.
  • Language independent
    A XML Web service or a connection to an XML Web Services can be written in any language provided it maintains the XML Web Services Standards.
  • Protocol independent
    Since they are communicate by using standard Web protocols and data formats, such as HTTP, XML and SOAP, any server that support these standards can access or host XML Web Services.
  • Platform independent
    Because XML Web Services are accessible through a standard interface, they allow disparate systems to work together.
  • Stateless architecture
    Each response from a Web services is a new object with a new state. (With ASP.net State Management services to maintain state between requests, we can do)
  • Asynchronous
    Since the request object from the client application and response object from the XML Web Service are unique SOAP Envelopes, they are asynchronous. They do not require a shared connection.
  • Based on W3C
    XML Web services are based on World Wide Web Consortium (W3C).

Consuming Java Web Services using a .NET Client.

Let us start our interoperability project by creating a Java Web Services and consuming it by a .NET Client.

Creating a java Web service:

Creating web services in java becomes very simple with lots of tools like AXIS and GLUE in to the picture. Here, I am using Rational Application Developer 6.0 to create the web service.

  1. Start the  Rational Application Developer Studio
  2. Select File>New>Project launching the new Project wizard.
  3. Expand the web folder and select Dynamic Web Project and click next.
  4. In the Dynamic Web Project window enter CincomWS and click Finish.
  5. Within the project explorer, expand CincomWS and Java Resources folder.
  6. Right click the JavaSource folder and select New > Class.
  7. Enter the package name as com.cincom and class name as Welcome.
  8. Now create a method hiFromCincom and make sure the Welcome.java contains the following lines.

    package com.cincom;
    public class Welcome
    {
              public String hiFromCincom(String strNameFromClient)
              {
                        return "HI " + strNameFromClient + ", Welcome to Cincom Java Web Services World.";
              }
    }

  9. Select File > New > Other.
  10. Select show all wizards and select Web Service. Click Next.
    NOTE: A window might appear telling you that you need to activate Web Service Development features. Select Always enable capabilities and don't ask again.
  11. In the Web Services window, select Generate a proxy. You can choose the Test the Web Service option also for creating a test client.
  12. Click Next.
  13. In the next window, enter com.cincom.Welcome as the bean and click Next.
  14. Select the Service web project cincomWS and EAR Project cincomWSEAR.
  15. In the Java Bean Identity window, check the hiFromCincom method and click Finish.

Now our first Java web service is created. We can see the wsdl with the link

http://localhost:9080/CincomWS/com/cincom/wsdl/Welcome.wsdl

Consuming the web service using .NET client:

  1. Open the Microsoft Visual Studio .NET
  2. Select File > New > Project then Visual C# projects and Asp.net Web application and enter http://localhost/WSClient to the location field.
  3. Add a reference of the above web service.
    This can be done in two ways:

    I-Using Visual Studio .NET
    • Right click on the References and click Add web reference...
    • Enter http://localhost:9080/CincomWS/com/cincom/wsdl/Welcome.wsdl to the URL field of the Add web reference and click go.
    • Enter cincomWS to the Web reference name field and click add reference
    II-Using WSDL.exe
    • Open a DOS Command prompt.
    • Run wsdl http://localhost:9080/CincomWS/com/cincom/wsdl/Welcome.wsdl it will create WelcomeService.cs file
    • Then run
       csc /t:library /r:System.dll,System.Web.Services.dll,System.Xml.dll   WelcomeService.cs
    • The above will created WelcomeService.dll
    • Now copy this dll to bin folder of WSClient folder or add a reference (not web reference)  of it to the WSClient project.
    NOTE: The proxy file created by WSDL.exe is static while the one that are created automatically by the Web reference is dynamic. If we want adding authentication, using WSDL.exe is the best approach as you can guarantee that the file will remain under your control.
  4. In the design view of the WebForm1.aspx, Add a Text box, one Label and one Button.
  5. Double click on the Button and make sure the Click function of the button is as follows.
     

    private void Button1_Click(object sender, System.EventArgs e)

    {

              cincomWS.Welcome cs = new cincomWS.Welcome();

              //if You are using the WelcomeService.dll comment the above    

          //line add a reference of System.Web.Services

          //and uncomment the line bellow

              //WelcomeService cs = new WelcomeService();

              String strName;

              if (TextBox1.Text.Equals(""))

              {

                        strName = "Client";

              }

              else

              {

                        strName = TextBox1.Text;

              }

              Label1.Text = cs.hiFromCincom(strName);
    }


  6. Now run the project.
  7. Put a name (YOURNAME) in the Text Box and then click the Button.
  8. The text of the Label will change to

    HI YOURNAME, Welcome to Cincom Java Web Services World.

Consuming .NET Web Services using a java Client.

Now, in this section we are going to create a .NET Web Services and consuming it by a java Client.

Creating a .NET Web Services:

  1. Start Visual Studio .NET and Select New > Project > Visual C# Project > ASP.NET Web Service
  2. Write http://localhost/cincomWS on the location field.
  3. Rename the Service1.asmx to Welcome.asmx
  4. Create a web method called hiFromCincom as follows

    [WebMethod]

    public string hiFromCincom(String strNameFromClient)

    {

              return "HI " + strNameFromClient + ", Welcome to Cincom .NET Web Services World.";

    }

  5. Now run the project
  6. Check the url http://localhost/cincomWS/Welcome.asmx
  7. And check http://localhost/cincomWS/Welcome.asmx?WSDL for WSDL

Consuming the web service using java client:

For creating the java proxies for that .NET Web service, we are going to use GLUE, by The Mind Electric, which is a framework for developing and publishing Web services. Get an evaluation version from http://www.webmethods.com/meta/default/folder/0000008629 and install it.

  1. Run the DOS command prompt
  2. Make a folder for your own choice say JavaClient
  3. Change the current working directory JavaClient
  4. Run the command wsdl2java http://localhost/cincomWS/Welcome.asmx?WSDL
    Two files are generated.
     IWelcomeSoap.java and WelcomeHelper.java
  5. Now create a java file Client.java in the same folder
  6. Past the following code to the file

    public class Client

    {

      public static void main(String[] args) throws Exception

      {

        String url = "http://localhost/cincomWS/Welcome.asmx?WSDL";  

              IWelcomeSoap welcome = WelcomeHelper.bind();

              String strName;

              if (args.length == 0)

              {

                        strName = "Client";

              }

              else

              {

                        strName = args[0];

              }

        System.out.println("\n"+ welcome.hiFromCincom(strName));    

      }

    }

  7. Now compile the files with javac *.java
  8. Run the client java Client YOURNAME

    You will get an output as

    HI YOURNAME, Welcome to Cincom .NET Web Services World.


Login to add your contents and source code to this article
 About the author
 
Laishram Priyokumar
MCSD .NET and Brainbench Advance Java certified Senior Engineer. Working with Cincom System India Pvt. Ltd and well experienced in .NET and J2EE technologies with strong RDBMS knowledge.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
 
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Powerful ASP.NET Hosting w/ NO Setup Fees. Click Here!
Become a Sponsor
 Comments
Session lossing by prasad On July 19, 2007
Hi, Priyokumar, I have one jsp application. In that there is JSP login page is there . when the user logins in login page he will move next page in that page there is 2 frame sets in my application. first frame set is jsp application (Login , logout, home are in one frame set) this is common for all pages and this application is running in one server . This server is maintaining sessions for that user. 2nd frame set is for asp.net(c#) Pages this is in different server. Problem : when the user is try to login I want to maintain these all values in sessions. I am reading values in aspx page through querystrings ge there I am assigning these query string to sessions . but I am reading these query string in aspx page but when I try to assign these querystrings to sessions it is not working .(I am losing session within a second) Please give me direction Regards Prasad Talla prasad.talla@wipro.com
Reply | Email | Delete | Modify | 
How to Call Java method in the .Net webservice by saidireddy On October 4, 2007
I want to call a method, which is in Java application, in the .Net webservice. And I will use this webservice in my .Net application. because in my project we wouldn't touch java application and we have to communicate with that java application through .Net please give me information on this issue. If you have any documents please send to my mail id saidireddy_basireddy@yahoo.com
Reply | Email | Delete | Modify | 
How to cosume axis web service in .NET client. by Ritesh On February 8, 2008
Hi, I tried your code in my application. But i get the null response in my application. i called the axis web service method having passing some parameter to it. but i am getting the null valus in response.what is my question is that before passing the parameter to axis web service function. should i encode it in some format or is there any other way to pass parameter to web service function. I used the following to code to access the axis web service. plz, help me protected void Page_Load(object sender, EventArgs e) { UsernameTokenProvider token = null; token = new UsernameTokenProvider("", ""); staging.CustomerRelationMgmtInterfaceService myservice = new staging.CustomerRelationMgmtInterfaceService(); //myservice.RequestEncoding = System.Text.Encoding.UTF8; string str ; str = myservice.paymentSummary("TST-2008-00662"); } But i get the "" values in str variable.
Reply | Email | Delete | Modify | 
Java equivalent types for .Net WS by Paul On July 14, 2009
Thanks for your tutorial!!!
Now, if I want to use another types instead of strings or integers. For example, if I have a web method in a .Net WS which expect to recieve a XMLDocument as an argument. How can I send the appropiate type from a java client since there's no direct equivalent of a .Net XMLDocument in Java?
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2010  Mindcracker LLC. All Rights Reserved