Click here to Skip to main content
12,694,121 members (35,411 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" %>

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

QuestionIs it me or does this just convert a C# web service to a Java one? Pin
riahc32-Jun-12 22:19
memberriahc32-Jun-12 22:19 
GeneralProblem calling update method of the webservice Pin
Pradeepchy12-Nov-09 23:24
memberPradeepchy12-Nov-09 23:24 
GeneralGetting PKIX error while trying to connect a .net webservice by java client Pin
Member 449278526-Aug-09 4:49
memberMember 449278526-Aug-09 4:49 
GeneralError while invoking webmethod - USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pin
moodbidri2-Jul-09 0:21
membermoodbidri2-Jul-09 0:21 
GeneralRe: Error while invoking webmethod - USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pin
moodbidri2-Jul-09 0:59
membermoodbidri2-Jul-09 0:59 
GeneralRe: Error while invoking webmethod - USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pin
moodbidri2-Jul-09 0:59
membermoodbidri2-Jul-09 0:59 
GeneralRe: Error while invoking webmethod - USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE Pin
Fahad Azeem2-Jul-09 6:31
memberFahad Azeem2-Jul-09 6:31 
Questionwsdl2java error Pin
Prince_Taj22-May-07 21:30
memberPrince_Taj22-May-07 21:30 
AnswerRe: wsdl2java error Pin
activea_12-Jun-07 1:59
memberactivea_12-Jun-07 1:59 
QuestionConsuming a java web service???? Pin
buzz101-zn18-May-07 7:34
memberbuzz101-zn18-May-07 7:34 
GeneralProblem writing c# web client Pin
guilho11-Apr-07 12:22
memberguilho11-Apr-07 12:22 
GeneralRe: Problem writing c# web client Pin
Fahad Azeem12-Apr-07 6:27
memberFahad Azeem12-Apr-07 6:27 
GeneralRe: Problem writing c# web client Pin
guilho13-Apr-07 6:19
memberguilho13-Apr-07 6:19 
GeneralRe: Problem writing c# web client Pin
Fahad Azeem16-Apr-07 12:55
memberFahad Azeem16-Apr-07 12:55 
GeneralError consuming the service Pin
Ravi Gurbaxani17-Jan-07 3:46
memberRavi Gurbaxani17-Jan-07 3:46 
GeneralRe: Error consuming the service Pin
Fahad Azeem17-Jan-07 16:31
memberFahad Azeem17-Jan-07 16:31 
GeneralRe: Error consuming the service Pin
Ravi Gurbaxani17-Jan-07 18:48
memberRavi Gurbaxani17-Jan-07 18:48 
QuestionWeb servers in jbuilder Pin
mesbih6-Jan-07 8:39
membermesbih6-Jan-07 8:39 
AnswerRe: Web servers in jbuilder Pin
Fahad Azeem8-Jan-07 12:25
memberFahad Azeem8-Jan-07 12:25 
News Pin 3:25
suss 3:25 
Generalhoe to pass user credentials Pin
a_s_a23-May-06 20:42
membera_s_a23-May-06 20:42 
GeneralRe: how to pass user credentials Pin
Fahad Azeem25-May-06 5:00
memberFahad Azeem25-May-06 5:00 
GeneralProblem with axis.jar Pin
Gowtam Kamath22-May-06 20:17
memberGowtam Kamath22-May-06 20:17 
GeneralRe: Problem with axis.jar Pin
Fahad Azeem23-May-06 12:59
memberFahad Azeem23-May-06 12:59 
GeneralRe: Problem with axis.jar Pin
Gowtam Kamath23-May-06 20:41
memberGowtam Kamath23-May-06 20: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.<init>(
at org.apache.axis.configuration.FileProvider.configureEngine(
at org.apache.axis.AxisEngine.init(
at org.apache.axis.AxisEngine.<init>(
at org.apache.axis.client.AxisClient.<init>(
at org.apache.axis.client.Service.getAxisClient(
at org.apache.axis.client.Service.<init>(
at com.ABC.PPDSWebService.PPDSWebServiceLocator.<init>(
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.


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
Web01 | 2.8.170118.1 | Last Updated 16 Apr 2004
Article Copyright 2004 by Fahad Azeem
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid