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
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

GeneralRe: how to pass user credentials PinmemberFahad Azeem25-May-06 4:00 
GeneralProblem with axis.jar PinmemberGowtam Kamath22-May-06 19:17 
GeneralRe: Problem with axis.jar PinmemberFahad Azeem23-May-06 11:59 
GeneralRe: Problem with axis.jar PinmemberGowtam Kamath23-May-06 19:41 
Hi Sir,
Thanks for replying.
Please validate my understanding of your reply.
The WebService I am using are 1)PPDSWebService and 2)VASEWebService.
Let me talk about PPDSWebService, as the other one is similar.
By following the steps as in ur article following .java files were generated
with a directory structure(package) of com.ABC.PPDSWebService
and 2 additional classes similar to those in .NET
Similarly for VASEWebService, 4 java files for webservice and few additional java files(similar to .NET) were generated with a directory structure of

As per your answer, I searched for the url field in all the classes generated as mentioned above.But i did not get any entry called "localhost".
In PPDSWebServiceLocator file,there was URL field pointing to the DNS name of the system having .NET WebService.
So, i guess i have not understood your reply properly.Sorry.
And, I apologise for not mentioning the problem properly.
I have detailed out the reason.I will be thankful to you if u read the following with enough patience.
Actually,I am working in Oracle APPS.
I have placed all the java files(compiled and created as JAR)in the server machine(where ORACLE APPS is installed - have written a JSP to access the WebService.When I execute the JSP in my browser(as client for the server - it is working perfectly fine and it is true with all other client systems.The java files for the webservices are not in my local system.It is in the server.
For this to happen I have placed following Apache Axis jars in the classpath in the server.because my JSPs placed in the server in a different directory need to access those jars
- axis.jar
- jaxrpc.jar
- saaj.jar
- soap.jar
- wsdl4j-1.5.1.jar
- commons-logging-1.0.4.jar
- commons-discovery-0.2.jar
I have compiled the java classes of webservice and created a JAR called com.jar and have placed it in the classpath.
The problem is,
Now we need to use the customer's system as our server.
So i placed all JSPs,servlet in the remote server( but not JARs
When i accessed the JSP without placing any of the Apache Jars and com.jar(webservice), the error is "PPDSWebServiceLocator class is not found".
Now i placed com.jar in the classpath.
When i called JSP again, the next error is "org/apache/axis/client/Service.class not found".Now i placed axis.jar in the classpath
So, when i executed the same JSP again, next error was
"javax/xml/rpc/ServiceException.class not found".Now i placed jaxrpc.jar in classpath.
Similarly, next error is "org/apache/commons/discovery/tools/DiscoverSingleton".Now i placed commons-logging-1.0.4.jar.
Similarly, next error is "org/apache/commons/discovery/tools/DiscoverSingleton".I placed commons-discovery-0.2.jar in the classpath.
Next error is "org/xml/sax/ContentHandler". Placed xerces.jar in the classpath.
Next error being "javax/xml/soap/SOAPException". For this I placed saaj.jar.
Now I am getting the error(which i am not able to rectify)
Exception in thread "main" java.lang.NoSuchMethodError
at org.apache.axis.deployment.wsdd.WSDDDocument.setDocument(
at org.apache.axis.deployment.wsdd.WSDDDocument.(
at org.apache.axis.configuration.FileProvider.configureEngine(
at org.apache.axis.AxisEngine.init(
at org.apache.axis.AxisEngine.(
at org.apache.axis.client.AxisClient.(
at org.apache.axis.client.Service.getAxisClient(
at org.apache.axis.client.Service.(
at com.ABC.PPDSWebService.PPDSWebServiceLocator.(
at XXASOBRKGPSS_Controller.main(
I do not know the reason behind this error.The classes shown in the stackTrace are present in "axis.jar"
In our server(, i am using the same "axis.jar" without any probelm.Do not know what is going wrong in accessing the same jar from the customers server.
One difference to note down is that,
customers server doesnt ask for "wsdl4j-1.5.1.jar",where as our server asks for it.
customer server requires "xerces.jar", where as our local server doesnt ask for it.

Thanks for the time spent for me.
Waiting for a good tip of solution from you.





GeneralRe: Problem with axis.jar PinmemberRameshtcs18-Jan-07 17:15 
GeneralRe: Problem with axis.jar Pinmembersonal_hotmail29-May-08 1:03 
Generalthe other way around Pinmemberoxygen_fiend18-May-06 18:28 
GeneralRe: the other way around PinmemberFahad Azeem19-May-06 3:39 
GeneralRe: the other way around Pinmemberoxygen_fiend19-May-06 14:03 
GeneralRe: the other way around PinmemberFahad Azeem19-May-06 16:34 

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 | Mobile
Web03 | 2.8.140821.2 | Last Updated 16 Apr 2004
Article Copyright 2004 by Fahad Azeem
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid