Click here to Skip to main content
13,352,298 members (73,846 online)
Click here to Skip to main content
Add your own
alternative version


28 bookmarked
Posted 15 Apr 2004

Consuming a .NET Web Service with Apache AXIS

, 15 Apr 2004
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

QuestionSSL connection with Apache Axis Pin
wouter devers19-Nov-05 5:53
memberwouter devers19-Nov-05 5:53 
AnswerRe: SSL connection with Apache Axis Pin
Fahad Azeem21-Nov-05 10:38
memberFahad Azeem21-Nov-05 10:38 
QuestionHow to Set User Credential in Apache AXIS Pin
1sttiger7-Oct-05 7:07
member1sttiger7-Oct-05 7:07 
AnswerRe: How to Set User Credential in Apache AXIS Pin
Fahad Azeem7-Oct-05 7:57
memberFahad Azeem7-Oct-05 7:57 
GeneralSoap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pin
santtarius28-Sep-05 20:56
membersanttarius28-Sep-05 20:56 
GeneralRe: Soap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pin
Fahad Azeem29-Sep-05 5:14
memberFahad Azeem29-Sep-05 5:14 
GeneralRe: Soap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pin
santtarius29-Sep-05 22:44
membersanttarius29-Sep-05 22:44 
GeneralSoap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pin
santtarius28-Sep-05 20:55
membersanttarius28-Sep-05 20:55 

I am Santhosh here.I am using Apache Axis1.2 to invoke a .NET webservice in my project.I generated stub classes using WSDL2Java.But when i run my client i get the exception as -

Exception Generated is :: Server was unable to process request. --> The
message must contain a wsa:To header

Please let me know what i need to do.If this exception is because of not setting SOAP header please send me a sample implementation code which does this setting.I have tried all the option to set the header and also i have used Axis2.I am not able to solve this problem.A solution would be greatly appreciated as i am struggling from few days to solve this.Please help me.

Santhosh Kumar N
Generaljava2wsdl Pin
jasonchewy27-Jun-05 5:06
memberjasonchewy27-Jun-05 5:06 
GeneralRe: java2wsdl Pin
jasonchewy27-Jun-05 5:22
memberjasonchewy27-Jun-05 5:22 
GeneralRe: java2wsdl Pin
Fahad Azeem28-Jun-05 17:04
memberFahad Azeem28-Jun-05 17:04 
GeneralThanks! Pin
homerbush18-May-05 19:41
memberhomerbush18-May-05 19:41 
GeneralRe: Thanks! Pin
Fahad Azeem20-May-05 18:27
memberFahad Azeem20-May-05 18:27 
GeneralRe: Questions Pin
1sttiger4-Oct-05 14:49
member1sttiger4-Oct-05 14:49 
GeneralRe: Questions Pin
1sttiger7-Oct-05 7:00
member1sttiger7-Oct-05 7:00 
Generalconsuming AXIS ws with C# Pin
Anonymous24-Jan-05 13:07
sussAnonymous24-Jan-05 13:07 
GeneralRe: consuming AXIS ws with C# Pin
Fahad Azeem25-Jan-05 4:40
memberFahad Azeem25-Jan-05 4:40 

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.

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