Click here to Skip to main content
Click here to Skip to main content

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:

Comments and Discussions

AnswerRe: How to Set User Credential in Apache AXIS PinmemberFahad Azeem7-Oct-05 7:57 
GeneralSoap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pinmembersanttarius28-Sep-05 20:56 
GeneralRe: Soap Fault : Server unable to process request --&gt; The request must contain wsa:To header PinmemberFahad Azeem29-Sep-05 5:14 
GeneralRe: Soap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pinmembersanttarius29-Sep-05 22:44 
GeneralSoap Fault : Server unable to process request --&gt; The request must contain wsa:To header Pinmembersanttarius28-Sep-05 20:55 
Generaljava2wsdl Pinmemberjasonchewy27-Jun-05 5:06 
GeneralRe: java2wsdl Pinmemberjasonchewy27-Jun-05 5:22 
GeneralRe: java2wsdl PinmemberFahad Azeem28-Jun-05 17:04 
GeneralThanks! Pinmemberhomerbush18-May-05 19:41 
GeneralRe: Thanks! PinmemberFahad Azeem20-May-05 18:27 
GeneralRe: Questions Pinmember1sttiger4-Oct-05 14:49 
GeneralRe: Questions Pinmember1sttiger7-Oct-05 7:00 
Generalconsuming AXIS ws with C# PinsussAnonymous24-Jan-05 13:07 
GeneralRe: consuming AXIS ws with C# PinmemberFahad Azeem25-Jan-05 4:40 
yes it is. You can generate a proxy class for your AXIS web service with wsdl.exe
and just use that class as your using a local class. This class will take care of
all the messaging etc
wsdl.exe -
Utility to generate code for xml web service clients and xml web services
using ASP.NET from WSDL contract files, XSD schemas and .discomap discovery
documents. This tool can be used in conjunction with disco.exe.
wsdl.exe <options> ...
A url or path to a WSDL contract, an XSD schema or .discomap document.
Suppresses the banner.
The language to use for the generated proxy class. Choose from 'CS',
'VB', 'JS', 'VJS' or provide a fully-qualified name for a class
implementing System.CodeDom.Compiler.CodeDomProvider. The default is 'CS'
(CSharp). Short form is '/l:'.
Generate an abstract class for an xml web service implementation using
ASP.NET based on the contracts. The default is to generate client proxy
The namespace for the generated proxy or template. The default namespace
is the global namespace. Short form is '/n:'.
The filename for the generated proxy code. The default name is derived from
the service name. Short form is '/o:'.
Override the default protocol to implement. Choose from 'SOAP', 'SOAP12',
'HttpGet', 'HttpPost', or custom protocol as specified in the configuration
The credentials to use when the connecting to a server that
requires authentication. Short forms are '/u:', '/p:' and '/d:'.
The url of the proxy server to use for http requests.
The default is to use the system proxy setting.
The credentials to use when the connecting to a proxy server that
requires authentication. Short forms are '/pu:', '/pp:' and '/pd:'.
The configuration key to use in the code generation to read the default
value for the Url property. The default is to not read from the config
file. Short form is '/urlkey:'.
The base url to use when calculating the url fragment. The
appsettingurlkey option must also be specified. The url fragment is
the result of calculating the relative url from the appsettingbaseurl
to the url in the WSDL document. Short form is '/baseurl:'.
Print errors in a format similar to those reported by compilers.
Nothing is impossible.....even impossible has the word possible

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web01 | 2.8.141220.1 | Last Updated 16 Apr 2004
Article Copyright 2004 by Fahad Azeem
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid