Click here to Skip to main content
12,454,477 members (56,654 online)
Click here to Skip to main content
Add your own
alternative version


28 bookmarked

Consuming a .NET Web Service with Apache AXIS

, 15 Apr 2004 Apache
Rate this:
Please Sign up or sign in to vote.
Consuming a .NET Web Service with Apache AXIS.


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 <A href="http://localhost/HelloWorld.asmx?WSDL">http://localhost/HelloWorld.asmx?WSDL</A>

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


This is how the client program looks like:

package org.tempuri;
public class Client
      public static void main(String [] args)
                  HelloWorldLocator loc = new HelloWorldLocator();
                  HelloWorldSoap port = loc.getHelloWorldSoap();
            catch(Exception e)

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.


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


About the Author

Fahad Azeem
Web Developer
United States United States
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:

You may also be interested in...


Comments and Discussions

GeneralRe: Problem writing c# web client Pin
Fahad Azeem12-Apr-07 5:27
memberFahad Azeem12-Apr-07 5:27 
GeneralRe: Problem writing c# web client Pin
guilho13-Apr-07 5:19
memberguilho13-Apr-07 5:19 
GeneralRe: Problem writing c# web client Pin
Fahad Azeem16-Apr-07 11:55
memberFahad Azeem16-Apr-07 11:55 
GeneralError consuming the service Pin
Ravi Gurbaxani17-Jan-07 2:46
memberRavi Gurbaxani17-Jan-07 2:46 
I have been using NetBeans5.0,Tomcat 5.0 and latest version of Axis.
My target is to consume a web service from But I am not able to do it.
I am getting following error
"C:\MyJavaPrograms\MyWebServices\nbproject\build-impl.xml:281: taskdef class cannot be found"

Let me share with you the procedure I followed:
Step 1: I copied the wsdl file called Global Weather from
Step 2: I used wsdl2 Java and I got four files
Step 3: I have written code for consuming the service.

I am putting the code for my Java File and the WSDL command I used.

One more thing. I work in a software company and we have proxy alos so please suggest me a solution.
public class Weather {

/** Creates a new instance of Weather */

public static void main(String [] args)
String Country="India";
GlobalWeatherLocator loc = new GlobalWeatherLocator();
GlobalWeatherSoap port = loc.getGlobalWeatherSoap();
catch(Exception e)
java org.apache.axis.wsdl.WSDL2Java http://localhost:8000/Latest/globalweather.wsdl

But, please remember this service is from teh internet.

Pleaase help me out

GeneralRe: Error consuming the service Pin
Fahad Azeem17-Jan-07 15:31
memberFahad Azeem17-Jan-07 15:31 
GeneralRe: Error consuming the service Pin
Ravi Gurbaxani17-Jan-07 17:48
memberRavi Gurbaxani17-Jan-07 17:48 
QuestionWeb servers in jbuilder Pin
mesbih6-Jan-07 7:39
membermesbih6-Jan-07 7:39 
AnswerRe: Web servers in jbuilder Pin
Fahad Azeem8-Jan-07 11:25
memberFahad Azeem8-Jan-07 11:25 
News Pin 2:25
suss 2:25 
Generalhoe to pass user credentials Pin
a_s_a23-May-06 19:42
membera_s_a23-May-06 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 16 Apr 2004
Article Copyright 2004 by Fahad Azeem
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid