Click here to Skip to main content
6,291,124 members and growing! (16,087 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » .NET Framework » How To     Intermediate License: The Apache License, Version 2.0

Consuming a .NET Web Service with Apache AXIS

By Fahad Azeem

Consuming a .NET Web Service with Apache AXIS.
C#, Java, .NET, Win2K, WinXP, Win2003, ASP.NET, Visual Studio, Apache, Dev
Posted:15 Apr 2004
Views:110,919
Bookmarked:18 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
20 votes for this article.
Popularity: 4.89 Rating: 3.76 out of 5
1 vote, 5.0%
1
2 votes, 10.0%
2
4 votes, 20.0%
3
2 votes, 10.0%
4
11 votes, 55.0%
5

Introduction

In this article, I will present an example on how to develop a typical HelloWorld Web Service with .NET on IIS, and how to consume that service with Apache AXIS in Java. Apache AXIS is SOAP implementation provided by Apache. AXIS SOAP implementation is available in two languages, C++ and Java. In this article, I will use the Java implementation of AXIS SOAP. Apache AXIS can be downloaded from here.

HelloWorld.asmx file is a simple text file in C#. The class HelloWorld just extends with the class WebService and implements a method SayHelloWorld(). To make this method a web method, it is given the attributed [WebMethod]. IIS simply takes care of generating the SOAP message and the WSDL file for the client.

Web Service on IIS in .asmx file

<%@ WebService Language="C#" Class="HelloWorld" %>
using System;
using System.Web.Services;
public class HelloWorld : WebService 
{
     [WebMethod] public String SayHelloWorld() 
     {
          return "Hello World";
     }
}

To consume this Web Service with AXIS, WSDL file for the HelloWorld Web Service needs to be downloaded.

Now, to consume this Web Service, Apache AXIS provides a tool WSDL2Java to convert WSDL specification file to Java code. This tool generates the four Java classes, and that will take care of processing XML and SOAP messaging, and makes the use of Web Service as simple as calling an object on a local machine.

> java org.apache.axis.wsdl.WSDL2Java http://localhost/HelloWorld.asmx?WSDL

The above tool will generate the following four class files which can be used to access that Web Service.

  • HelloWorld.java
  • HelloWorldLocator.java
  • HelloWorldSoap.java
  • HelloWorldSoapStub.java

This is how the client program looks like:

package org.tempuri;
public class Client
{
      public static void main(String [] args)
      {
            try
            {  
                  HelloWorldLocator loc = new HelloWorldLocator();
                  HelloWorldSoap port = loc.getHelloWorldSoap();
                  System.out.println(port.sayHelloWorld());
            }
            catch(Exception e)
            {System.out.println(e.getMessage());}
      }
}

Before coming across Apache AXIS, my reaction to developing and consuming Web Service in Java was that it was a lot of pain. But with Apache AXIS, developing and consuming Web Service is as simple as in .NET platform.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

About the Author

Fahad Azeem


Member
My name is Fahad Azeem. I am interested in distributed software development. Currently I am working for a software consulting company in Chicago which developes software in .NET platform.

My Blog: http://fahadaz.blogspot.com
Occupation: Web Developer
Location: United States United States

Other popular .NET Framework articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 57 (Total in Forum: 57) (Refresh)FirstPrevNext
GeneralError while invoking webmethod - java.net.UnknownHostException: USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pinmembermoodbidri0:21 2 Jul '09  
GeneralRe: Error while invoking webmethod - java.net.UnknownHostException: USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pinmembermoodbidri0:59 2 Jul '09  
GeneralRe: Error while invoking webmethod - java.net.UnknownHostException: USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pinmembermoodbidri0:59 2 Jul '09  
GeneralRe: Error while invoking webmethod - java.net.UnknownHostException: USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE PinmemberFahad Azeem6:31 2 Jul '09  
Questionwsdl2java error PinmemberPrince_Taj21:30 22 May '07  
AnswerRe: wsdl2java error Pinmemberactivea_1:59 12 Jun '07  
QuestionConsuming a java web service???? Pinmemberbuzz101-zn7:34 18 May '07  
GeneralProblem writing c# web client Pinmemberguilho12:22 11 Apr '07  
GeneralRe: Problem writing c# web client PinmemberFahad Azeem6:27 12 Apr '07  
GeneralRe: Problem writing c# web client Pinmemberguilho6:19 13 Apr '07  
GeneralRe: Problem writing c# web client PinmemberFahad Azeem12:55 16 Apr '07  
GeneralError consuming the service PinmemberRavi Gurbaxani3:46 17 Jan '07  
GeneralRe: Error consuming the service PinmemberFahad Azeem16:31 17 Jan '07  
GeneralRe: Error consuming the service PinmemberRavi Gurbaxani18:48 17 Jan '07  
QuestionWeb servers in jbuilder Pinmembermesbih8:39 6 Jan '07  
AnswerRe: Web servers in jbuilder PinmemberFahad Azeem12:25 8 Jan '07  
Newshttp://casino-slots.ceroline.info/ Pinsusshttp://casino-slots.ceroline.info/3:25 4 Dec '07  
Generalhoe to pass user credentials Pinmembera_s_a20:42 23 May '06  
GeneralRe: how to pass user credentials PinmemberFahad Azeem5:00 25 May '06  
GeneralProblem with axis.jar PinmemberGowtam Kamath20:17 22 May '06  
GeneralRe: Problem with axis.jar PinmemberFahad Azeem12:59 23 May '06  
GeneralRe: Problem with axis.jar PinmemberGowtam Kamath20:41 23 May '06  
GeneralRe: Problem with axis.jar PinmemberRameshtcs18:15 18 Jan '07  
GeneralRe: Problem with axis.jar Pinmembersonal_hotmail2:03 29 May '08  
Generalthe other way around Pinmemberoxygen_fiend19:28 18 May '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 15 Apr 2004
Editor: Smitha Vijayan
Copyright 2004 by Fahad Azeem
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project