Home  |  FAQ  |  About  |  Contact  |  View Source   
 
SEARCH:
 
BROWSE:
    My Hood
Edit My Info
View Events
Read Tutorials
Training Modules
View Presentations
Download Tools
Scan News
Get Jobs
Message Forums
School Forums
Member Directory
   
CONTRIBUTE:
    Sign me up!
Post an Event
Submit Tutorials
Upload Tools
Link News
Post Jobs
   
   
Home >  Tutorials >  Web Services >  Interoperability of Web Services: Seeing is believing
Add to MyHood
Interoperability of Web Services: Seeing is believing   [ printer friendly ]
Stats
  Rating: 4.2 out of 5 by 10 users
  Submitted: 01/30/02
Jorge Balderas ()

 
Abstract
One of the big promises of web services is universal interoperability because of the use of platform and language independent protocols such as SOAP. My skepticism about this led me to build an experiment in order to prove that this theory was true in practice.

This experiment consists of the following two parts:
  • A Web service that converts temperatures from Fahrenheit degrees to Celsius degrees exposed using a web service engine for Java.
  • A Web service consumer in ASP .NET using Visual Basic.

This tutorial assumes basic understanding of Web Services, more specifically about SOAP (Simple Object Access Protocol) and WSDL (Web Services Description Language). It also assumes familiarity with the use of Visual Studio .NET and some understanding of Java.

The Java Web Service provider
The Web Services engine for java that I chose to use was , the Apache eXtensible Interactive System. AXIS is the successor of the implementation. Although the latest release is version alpha 3, it has features that can significantly accelerate Web Services development, and resemble some that are present in Microsoft .NET:
  1. Easy creation. Simply take any .java source file, replace the extension with .jws and put it in the appropriate directory.
  2. Automatic exposure. The WSDL file is automatically generated by accessing the url of the web service and adding "?WSDL", just like in ASP .NET with .asmx files. For example: http://localhost/MyService.jws?WSDL
  3. Tool for generating service proxy. A program that takes as input a WSDL file and generates the proxy/stub classes for accessing the web service in Java. This tool is named Wsdl2java, and is the equivalent of wsdl.exe in the .NET framework.

I will not explain in detail how to setup AXIS (detailed instructions can be ), if you are familiar with other Apache software, the procedure will look familiar:
  1. In addition to the of your choice, you will need a Servlet/JSP Server implementation (e.g. Jakarta Tomcat). I used
  2. Additionally you need to get a JAXP 1.1 XML compliant parser, either or are fine, but the .jar files need to be included in the classpath, or copied into the lib directory.
  3. The "webapp" folder of axis needs to be copied into the webapps folder of tomcat and the axis .jar files need to be included in the classpath.
Next we need to create the actual web service code. This web service will include one method to convert Fahrenheit degrees to Celsius degrees. The file is to be named FToCService.jws and should be placed under the axis folder. The source code required for the Web Service looks like this:
/**  

 * Web Service for converting from Fahrenheit to Celsius degrees 
 */

public class FToCService {
    public static float FToC (int fahrenheit) {
        return (float)(fahrenheit-32)*5/9;
    }
}


The ASP .NET Web Service consumer
Now that the web service is created and exposed, we can use wsdl.exe from Microsoft .NET framework to generate a proxy class, which will be used by our ASP .NET application to consume the service. This is done from the Command Prompt:

C:\Inetpub\wwwroot\ws>wsdl /language:vb /namespace:JavaService http://localhost:8080/axis/FToCService.jws?WSDL

This generates the FToCService.vb which should be added to a ASP .NET Project in VB using Visual Studio .NET, and needs to be compiled. After doing this we can use it from a ASP .NET web form (named ServiceClient.aspx):



  <%@ Page Language="vb" Inherits="ws.ServiceClient" %>
<HTML> <SCRIPT runat="server"> Sub submitBtn_Click(sender As Object, e As EventArgs) Dim myService As New JavaService.FToCService() celsius.Text = myService.FToC(fahrenheit.text) & " °C" End Sub </SCRIPT> <BODY> <FORM method="post" runat="server"> <asp:TEXTBOX id="fahrenheit" runat="server" width="30" />°F <asp:Button id="submitBtn" runat="server" text="Convert" onclick="submitBtn_Click" /> <BR> <asp:LABEL id="celsius" runat="server" /> </FORM> </BODY> </HTML>

That's all that needs to be done. Upon submitting the form on ServiceClient.aspx, the java web service will be consumed, demostrating the interoperability and language independency of web services.

Return to Browsing Tutorials

Email this Tutorial to a Friend

Rate this Content:  
low quality  1 2 3 4 5  high quality

Reader's Comments Post a Comment
 
That's much better than the previous (mistakenly?) posted tutorial. I'll have to look up more information on Axis. Seems pretty interesting and a lot easier to setup than using Apache's soap.jar package.
-- Heath Stewart, January 30, 2002
 
You may also want to take a look at the , or as they are advertising it: One pack to build them all!
-- Jorge Balderas, January 31, 2002
 
It's definitely an improvement over the previous post. I think I'll check out the Axis info as well. Oh, nice reference Jorge.
-- Josh Vetere, January 31, 2002
 
Much better than the previous tutorial, Good Job!
-- Steve Hulin, February 01, 2002
 
Much better than the previous tutorial, Good Job!
-- manuel torres, February 14, 2002
 
Good job on this tutorial.
-- Reid Jonasson, March 06, 2002
 
Good tutorial.
-- Brian Simoneau, March 07, 2002
 
Improvement! I like to see it!
-- Sean Fitzgerald, March 14, 2002
 
Good tutorial and easy to read.
-- Jared Betteridge, March 27, 2002
 
Excellent experiment. Well written, organized and relelvant.
-- Dan Belcher, March 28, 2002
 
It's a nice tutorial. I was looking for an example like this one. But I have big problems when I try to do a web service like the one you made with one change. If the method expoxed returns a simple struct (a xsd defined complex type with a few elements), ASP.NET consumer can't build the struct correctly. I would like to have an example of a web service made in Axis with a method that returns a struct and an ASP.NET consumer that could use the web service correctly. It would by very important for me. Have you tried a similar example? It's works fine with the wsdl2java consumer but not with the consumer developed with ASP.NET

Thank you very much !
-- Gustavo López, August 30, 2002
 
Copyright © 2001 DevHood® All Rights Reserved