Prerequisites
- Must be familiar with Java
- Familiar with basics on a web server like Tomcat
- Some knowledge in configuring Axis will be an added advantage
System Configuration Requirements
We will be discussing the configuration in brief as our scope is mainly on web services. (If Axis already configured, jump to implementation). If you find any issues on the configuration part, you can refer to Apache Axis site for troubleshooting. (But if you can not solve it yourself do not worry, post the issue under the comments section in this article, and we’ll get back to you).JDK installation
These examples have been tested on a machine with JDK 1.6 version.
Web Server
You must have a web server installed; and we will be using Tomcat (5.5 version) web server. If you are not having one, better download Tomcat here{link} and install it yourself (it is quite easy to install Tomcat). Now your CATALINA_HOME environment variable should point to the Tomcat installation directory.
Apache Axis 1.4
Download Apache Axis 1.4. Extract the downloaded file and you’ll find a folder named “axis” inside webapps folder.
%Axis_1.4_dir%\webapps\axis
Copy this “axis” folder into your web server’s webapps folder.
%CATALINA_HOME%\webapps
CLASS PATH
Now you must add following libraries into your CLASSPATH environment variable. All of these are available under %Axis_1.4_dir%\lib folder.
- axis.jar
- commons-discovery.jar
- commons-logging.jar
- jaxrpc.jar
- log4j-1.2.8.jar
- saaj.jar
- wsdl4j.jar
Implementation - web service and client
The implementation will consist of two parts. First we will implement web service part; a Calculator will be exposed as a web service. Next a client to use this Calculator web service will be implemented. (Client part starts from here).Calculator Web Service
Implementing the web service consists of 7 steps. We will be explaining each step in detail.- Functionality provider
- Web service’s interface
- Java2WSDL - Generate WSDL file
- WSDL2Java - Generate server side and client side classes for web service
- Bind Web service with Functionality provider
- Bundle required classes
- Register web service with axis
Project structure
Before starting coding, we'll have a look at the project structure. We are using a separate folder for the project, called "WS-Sample". We will be creating source (.java) files under "WS-Sample\src" folder and storing generated class (.class) files under a "WS-Sample\classes" folder.1. Functionality provider
First we need to write class with calculator functionality before exposing it as a web service. We have implemented it as a pretty complex high end calculator class, named SimpleCalculator and it's listed below. (It is just a pretty simple class with three methods). This class has no information related to a web service and has been written as a simple independent class. So in the time this class was written, no one has thought of any web service stuff. But we will expose this class as a web service. (Yes, what you guessed is correct. Later you can expose your existing Java classes as web services.)
package org.kamal.wssample;
public class SimpleCalculator {
public int add(int a, int b) {
return a + b;
}
public int subtract(int a, int b) {
return a - b;
}
public int multiply(int a, int b) {
return a * b;
}
}
WS-Sample\src> javac -d ..\classes
org\kamal\wssample\SimpleCalculator.java
2. Web service’s interface
Now we should write an interface that defines the services that will be provided by our web service. We will expose only two methods through our service; add() and subtract() methods (although we can expose any number of services within one web service). We did choose only two methods to emphasize the fact that we can control which methods we expose. And we will write this class in a separate package; org.kamal.wssample.ws.
package org.kamal.wssample.ws;
public interface Calculator {
int add (int x, int y);
int subtract(int x, int y);
}
WS-Sample\src> javac -d ..\classes
org\kamal\wssample\ws\Calculator.java
3. Java2WSDL - Generate WSDL file
Axis has a tool called Java2WSDL, which generates a WSDL file for a web service using a Java class. We should use the Calculator interface and generate WSDL file as follows. Java2WSDL file requires the Calculator.class file (not Calculator.java) for the operation. Also we will provide the following information.- o – name for WSDL file -> calculator.wsdl
- n – target namespace -> urn:org.kamal.calculator
- l – url of web service -> http://localhost:8080/axis/services/calculator
WS-Sample\classes> java org.apache.axis.wsdl.Java2WSDL
-o ..\calculator.wsdl
-n urn:org.kamal.calculator
-l http://localhost:8080/axis/services/calculator
org.kamal.wssample.ws.Calculator
4. WSDL2Java - Generate server side and client side classes for web service
Axis has another tool named WSDL2Java, which can generate server side and client side Java classes using a WSDL file. These classes are needed for deploying the web service and for accessing the service by a Java client. This tool must be provided with WSDL file that we generated in the previous step. It needs the following information as well.- o – output folder -> src
- p – package for generated classes -> org.kamal.wssample.ws.generated
- s – generate server side classes as well
WS-Sample> java org.apache.axis.wsdl.WSDL2Java
-o src
-p org.kamal.wssample.ws.generated
-s
calculator.wsdl
- Calculator.java
- CalculatorService.java
- CalculatorServiceLocator.java
- CalculatorSoapBindingImpl.java
- CalculatorSoapBindingStub.java
- deploy.wsdd
- undeploy.wsdd
WS-Sample\src> javac –d ..\classes
org\kamal\wssample\ws\generated\*.java
5. Bind Web service with Functionality provider
As you may have noted; even though we wrote org.kamal.wssample.SimpleCalculator class at the start, we have not used it so far. Now we are going to bind it to the web service.There is a class named CalculatorSoapBindingImpl inside org.kamal.wssample.ws.generated package. This is the class used to bind our existing SimpleCalculator class to the web service calls. In CalculatorSoapBindingImpl class, there are two methods; add() and subtract(). In this class, we can use the SimpleCalculator to call the actual methods as follows.
package org.kamal.wssample.ws.generated;
import org.kamal.wssample.SimpleCalculator;
public class CalculatorSoapBindingImpl implements
org.kamal.wssample.ws.generated.Calculator {
private SimpleCalculator calc = new SimpleCalculator();
public int add(int a, int b) throws java.rmi.RemoteException {
return calc.add(a, b);
}
public int subtract(int from, int x) throws java.rmi.RemoteException {
return calc.subtract(from, x);
}
}
6. Bundle required classes
Now we will create a jar file with all these classes, so that we can use it for deploying our web service. Use the jar command as follows.
WS-Sample\classes> jar cvf ..\calculatorServerSide.jar
org\kamal\wssample\*.class
org\kamal\wssample\ws\*.class
org\kamal\wssample\ws\generated\*.class
WS-Sample> copy calculatorServerSide.jar
"%CATALINA_HOME%\webapps\axis\WEB-INF\lib"
We will create another jar file to use in the client side. For the client side we only need the classes that were generated by the WSDL2java tool (which are located inside org\kamal\wssample\ws\generated package), except the CalculatorSoapBindingImpl class.
WS-Sample\classes> jar cvf ..\calculatorClientSide.jar
org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.class
org\kamal\wssample\ws\generated\CalculatorServiceLocator.class
org\kamal\wssample\ws\generated\CalculatorService.class
org\kamal\wssample\ws\generated\Calculator.class
7. Register web service with axis
Axis comes with a tool for registering web services with Axis; it is called AdminClient. Look into org\kamal\wssample\ws\generated folder and you will find two WSDD (web service deployment descriptor) files; deploy.wsdd and undeploy.wsdd. These files were generated by WSDL2Java tool and as used in deploying/undeploying a web service.Note: (Tomcat) Server must be started before executing the following command.
WS-Sample\src> java org.apache.axis.client.AdminClient
org\kamal\wssample\ws\generated\deploy.wsdd
To verify our web service is deployed correctly; try following url from your browser.
http://localhost:8080/axis/services/calculator?wsdl
(change the port 8080 in url to match the port on your machine)
This will show up a complete wsdl file, and it is the complete definition of the web service that we have deployed.
Now everything on web service (server side) is completed and our web service is successfully deployed.
Web Service client
Now it’s time for us to write a client to access this web service and use provided services. For this we need the calculatorClientSide.jar file that we created in an earlier step.For the client side we will create a new project folder named “WS-Client” with sub folders named src, classes and lib. Copy the generated calculatorClientSide.jar file into the "WS-Client\lib" folder.
We will create the client as follows. Since our web service exposed two methods, add() and subtract(); client class will use the service and call those add() and subtract() methods.
package org.kamal.wsclient;
import org.kamal.wssample.ws.generated.Calculator;
import org.kamal.wssample.ws.generated.CalculatorService;
import org.kamal.wssample.ws.generated.CalculatorServiceLocator;
public class CalcClient {
public static void main(String[] args) throws Exception {
CalculatorService service = new CalculatorServiceLocator();
Calculator calc = service.getcalculator();
System.out.println("15 + 6 = " + calc.add(15, 6));
System.out.println("15 - 6 = " + calc.subtract(15, 6));
}
}
Compile the class with following command.
WS-Sample-Client\src> javac -classpath %CLASSPATH%;..\lib\calculatorClientSide.jar
-d ..\classes
org\kamal\wsclient\CalcClient.java
WS-Sample-Client\classes> java -cp %CLASSPATH%;.;..\lib\calculatorClientSide.jar
org.kamal.wsclient.CalcClient
15 + 6 = 21
15 – 6 = 9
As you can see, generating the client side is much easier than the server side.
I'm new to web services. Thanks this helped me a lot.
ReplyDeleteNice work, thanks.
ReplyDeleteThis is what i have been looking for simple easy to understand...my kind of tutorial
ReplyDeletethanks
kris
This error has caused because your CLASSPATH is incorrect.
ReplyDeleteCLASSPATH=E:\axis-1_4\lib
In setting the CLASSPATH, you should point to your jar files rather than the lib directory like;
CLASSPATH=E:\axis-1_4\lib\axis.jar;E:\axis-1_4\lib\commons-discovery.jar;.. etc.
Try that and let me know whether you could resolve the issue.
while compailing the generated class file the following is occur please help me,reply as soon as posible
ReplyDeleteC:\Users\COMPAQ-GTI\Desktop\work\axis-ex\WS-Sample\src>javac -d C:\Users\COMPAQ-GTI\Desktop\work\axi
s-ex\WS-Sample\classes.gen org\kamal\wssample\ws\generated\*.java
org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:32: as of release 1.5, 'enum' is a ke
yword, and may not be used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
oper.setStyle(org.apache.axis.enum.Style.RPC);
^
org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:33: as of release 1.5, 'enum' is a ke
yword, and may not be used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
oper.setUse(org.apache.axis.enum.Use.ENCODED);
^
org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:43: as of release 1.5, 'enum' is a ke
yword, and may not be used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
oper.setStyle(org.apache.axis.enum.Style.RPC);
^
org\kamal\wssample\ws\generated\CalculatorSoapBindingStub.java:44: as of release 1.5, 'enum' is a ke
yword, and may not be used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
oper.setUse(org.apache.axis.enum.Use.ENCODED);
^
4 errors
Hi,
ReplyDeleteAs the error message shows, it's due an invalid use of 'enum' keyword. What is the version that you are using, 1.4 or 1.5?
Let me know the followings you used.
1. JRE version
2. JDK version
Cheers.
Hi Uday,
ReplyDeleteYou must start Tomcat with Axis, before running this command. It seems your Tomcat server is not started yet. Try again after starting it.
thanks for reply
ReplyDeletei started tomcat(5.5),my os is vista, i set classpath pointing to alljar files in axis 1.4\lib
Hi Uday,
ReplyDeleteWere you able to resolve the issue after starting Tomcat?
thanks for reply
ReplyDeletehow to enable AdminService
Uday, you don't have to enable it explicitly, it should be enabled by default. (Not sure whether there's any restrictions on Vista).
ReplyDeleteKamal Mettananda
ReplyDeleteAn Excellent article for a newbie like me. Keep it up.
Thanks a lot.
Hi Srinivas,
ReplyDeleteThanks for your appreciation. It really encourages me.
Kamal
Hi Uday,
ReplyDeleteSeems you have been able to resolve the AdminService issue.
To resolve this exception, try adding the latest xerces jar to your class path.
Excellent tutorial, You made me life simpler. You should start writing books.
ReplyDeleteIf you have similar tutorial on WS-Management and Wiseman implementation, please share with me. My email address vponnuru23@yahoo.com
Hi vponnuru,
ReplyDeleteI'm really happy to hear your comments. At this moment, this is the only tutorial on web services (read other tutorials here).
Please subscribe through email or RSS (shown at the top of the site) to receive the latest content.
Hi,
ReplyDeleteWhen i am performing this step getting problem like
D:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
Processing file org\kamal\wssample\ws\generated\deploy.wsdd
Exception:: java.lang.NullPointerException
Kindly help me for the same.
Thanks,
Manjesh Kumar
Hi Manjesh,
ReplyDeleteDon't worry, we'll work together and get this resolved.
Can you post the complete stack trace, so that we can pick the place where this exception is thrown?
I am trying to create WS according to your guidance steps. i have complete till 6th steps successfully but when i am trying to perform 7th step as following
ReplyDeleteD:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
Processing file org\kamal\wssample\ws\generated\deploy.wsdd
Exception:: java.lang.NullPointerException
getting problem. Kindly help me.
Regards,
Manjesh Kumar
Manjesh,
ReplyDeleteIs this all that you see in the error message? Isn't there any other information in the error message?
I will need some more information as this does not tell anything that can be used in resolving the issue.
Hi,
ReplyDeleteCan i get any link to create axis ws using SOAP Monitor.
Thanks.
Manjesh Kumar
Hi Manjesh,
ReplyDeleteI'll try to post the details of setting up SOAP monitor as soon as possible. Please get subscribed through email, so that you will get notified.
Hi,
ReplyDeleteThanks, for such a nice article.Can u please also post some content on how to make a small part of already written application , a web service.My web App is already in place ,now i have to write a web service so that some PDF can access some functionality of my web App.Thanks, SS
Hi,
ReplyDeleteWhile I'm generating the server and client slide classes through the following command.
E:\jakarta-tomcat-5.0.28\webapps\axis>java org.apache.axis.wsdl.WSDL2Java -o src -p org.kamal.wssample.ws.generated -s NHLService.wsdl
I'm getting this error below:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/WSDL2Java
Hi,
ReplyDeleteI'll try to provide you with a post on exposing existing functionalities as web services.
Hi,
ReplyDelete// Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/WSDL2Java
Your CLASSPATH variable does not point to all necessary .jar files. Just add them as I have mentioned at the start of the tutorial and try again.
If you still have the issue, post us value of the CLASSPATH variable.
Thanks, this is really helpful.
ReplyDeleteI'm going to subscribe to your site to get updates.
Hi Kamal, i have seen your article and it's really a good one for a newbie to web services. I hope you will help me with some issues in dealing with Apache Axis..I have generated a a server side classes from the given WSDL. Also, i have written a client side API which interfaces with those proxy classes, which i generated from the wsdl using axis..Now, i have written a client-side java program that uses the Client side API to invoke the service on the Server side...for that java program, i have to pass a SOAP request and i couldn't figure it out how all these pieces interact and come into work...any suggestions would be of great help...have a good day
ReplyDeleteThanks a lot, this is pretty good
ReplyDeleteHi
ReplyDeleteWhy I never found axis.jar in the lib folder? There are only axis2-adb-1.4.1.jar, axis2-adb-codegen-1.4.1.jar, axis2-kernel-1.4.1.jar... axix-*** jar files.
Thanks.
// Why I never found axis.jar in the lib folder
ReplyDeleteSeems you have downloaded Axis2 rather than Axis 1.4. Please download Axis 1.4 from here.
Hi Manjesh,
ReplyDeleteTo find out the place where NullPointerException is thrown, can you give the full stack trace of the exception.
Hi Kamal,
ReplyDeleteafter executing all the steps, I got the following exception while running the client......... Can you say the reason. I didn't also got wsdl on IE for calculator
-------------
c:\WS-Sample\WS-Sample-Client\classes>java -classpath %CLASSPATH%;.;..\lib\calcu
latorClientSide.jar org.kamal.wsclient.CalcClient
- Unable to find required classes (javax.activation.DataHandler and javax.mail.i
nternet.MimeMultipart). Attachment support is disabled.
Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Server.NoService
faultSubcode:
faultString: The AXIS engine could not find a target service to invoke! target
Service is calculator
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:IND-1K151BSH1
The AXIS engine could not find a target service to invoke! targetService is cal
culator
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder
.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.
java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(Deserializ
ationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endEleme
nt(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scan
EndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
urce)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
known Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(Deserialization
Context.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnders
tandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at org.kamal.wssample.ws.generated.CalculatorSoapBindingStub.add(Calcula
torSoapBindingStub.java:118)
at org.kamal.wsclient.CalcClient.main(CalcClient.java:13)
c:\WS-Sample\WS-Sample-Client\classes>
me again. I could solve the problem. solution for me was this command:
ReplyDeleteset CLASSPATH=C:\axis-1_4\lib\axis.jar;C:\axis-1_4\lib\commons-discovery-0.2.jar;C:\axis-1_4\lib\commons-logging-1.0.4.jar;C:\axis-1_4\lib\jaxrpc.jar;C:\axis-1_4\lib\log4j-1.2.8.jar;C:\axis-1_4\lib\saaj.jar;C:\axis-1_4\lib\wsdl4j-1.5.1.jar;
as a help for others. I first was searching to find the solution in Eclipse in the project. Although I had to set the classpath with the command prompt.
Hi E-Nature,
ReplyDeleteThanks for sharing your experience with our readers.
Another alternative to this is to set an Environment variable named CLASSPATH with these libs.
Error at: "7. Register web service with axis"
ReplyDeletewrong:
java org.apache.axis.client.AdminClient
org\kamal\wsample\ws\generated\deploy.wsdd
correct (with two 's'):
java org.apache.axis.client.AdminClient
org\kamal\wssample\ws\generated\deploy.wsdd
// faultString: java.net.ConnectException: Connection refused: connect
ReplyDeleteSeems you haven't stared Tomcat before running the AdminClient. You must start Tomcat before running this.
// correct (with two 's'):
ReplyDeleteE-Nature, I'm fixing it right now.
Thanks for pointing.
Hi Kamal,
ReplyDeleteThanks for following answer, but I have started/restarted tomcat multiple times but without any success.
I changed the command to
java org.apache.axis.client.AdminClient -l http://localhost:8084/axis/services/AdminService /pathname/deploy.wsdd
and it worked.
// faultString: java.net.ConnectException: Connection refused: connect
Seems you haven't stared Tomcat before running the AdminClient. You must start Tomcat before running this.
Hi Kamal,
ReplyDeleteDo you have any step by step example where a external webservice is called using axis(wsdl2java) e.g. StockQuote.
Thanks.
//Connection refused: connect
ReplyDeleteWhat is the port that you are running tomcat?
This is excellent place to start learning web services. I do a question regarding the WS-Sample and WS-Sample-client directories you created. Should they be part of the Axis directory that we copied under \tomcat\webapps\axis or these directories are seperate projects that run in tomcat\webapps?
ReplyDeletePerfect, the only simple and strait forward Web Services tutorial on the web :))
ReplyDeleteConfiguring Axis1.4, tomact5.5 with jdk1.4 after configuring all are working fine. But while deployment I am not able to deploy wsdd file .In normal case tomcat 5.5 doesn’t support jdk 1.4,but after putting some jar inside tomcat 5.5 it’s working fine.I have added some jar (jmx.jar, xercesImpl.jar, xml-apis.jar) to make it tomcat5 compatible with jdk 1.4.
ReplyDeleteI Configured like that:
tomact 5.5
Axis 1.4
jdk 1.4
Hi Kamal,
ReplyDeleteGreat job and Great mind!!
A quick question that I have is, Axis 1.4 does not have bin directory, then how do I start the Axis server if I need.But Axis2 has bin folder.
Thanks, Eas
Dear Kamal,
ReplyDeleteIn continuation of my earlier comment, I rechecked once again carefully the classpath details and found that I had not linked the wsdl4j.jar. After correcting this and running step 3 for creating the wsdl file I get a message as under:
WS-Sample\classes> java org.apache.axis.wsdl.Java2WSDL
-o ..\calculator.wsdl
-n urn:org.kamal.calculator
-l http://localhost:8080/axis/services/calculator
org.kamal.wssample.ws.Calculator
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle)
log4j:WARN Please initialize the log4j system properly
java.lang.ClassNotFoundException: org.kamal.wssample.ws.Calculator
could you please guide to proceed further?
kbs.
Hi kbs,
ReplyDeleteCan you check whether this Calculator.class file is available inside classes/org/kamal/wssample/ws/ folder. This error means that the program can not find the specified .class file.
Hope this helps.
Hi Kamal,
ReplyDeleteThanks for your guidance. The class file was present but apparently it was due to my mistake of deleting the jre link in the classpath. Once this was rectified the wsdl creation went through. It did however give the following message.
log4j: WARN no appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle)
log 4j: WARN please initialize the log4j system properly
After running through all the steps, the final result however was interesting! (I am not sure if I would deserve a mathematics Nobel Prize for this!!)
There was the same warning and the final output was
15 + 6 = -3
15 - 6 = -3
The command line details are:
C:\WS-Sample-Client\classes> java
-cp %CLASSPATH%;.;..\lib\calcuatorClientSide.jar
org.kamal.wsclient.CalcClient
log4j: WARN no appenders could be found for logger org.apache.axis.i18n.ProjectResourceBundle
log 4j: WARN please initialize the log4j system properly
15 + 6 = -3
15 - 6 = -3
C:\WS-Sample-Client\classes>
I am looking forward to your guidance.
Thanks,
kbs
log4j warings: you can ignore them for the time being.
ReplyDeleteBut I can hardly guess how your results are always coming as -3. Have you checked your add() and subtract() methods?
Hi kbs,
ReplyDeleteYou haven't been following the steps, right? Have a look at step 5 named "Bind Web service with Functionality provider".
Kamal,
ReplyDeleteIt would be nice if you can rewrite your tutorial with annotations. I thought by using annotations you don't need to do anything other than to write the class
Hi Kamal,
ReplyDeleteThanks a lot for your guidance. I had indeed missed the crucial step 5. Once this was done it went through like a cake and I was delighted. Let me also join others in complimenting you for an excellent tutorial. While other tutorials give broad guidelines, yours was significantly different with minute details and step by step guidance. This brought home the concepts clearly.
Now having had some idea of the whole process, I have a suggestion to make, for your consideration. We are compiling the generated classes in step 4 itself before tweaking/editing the CalculatorSoapBindingImpl class in step 5 to bind the Web service with Functionality provider. I therefore feel that compiling the generated classes should be done after step 5 and not before. This could possibly help the uninitiated like me who follow the tutorial.
Thanks once again and looking forward to more such exhaustive tutorials in the days ahead.
With regards,
kbs.
Hello Kamal,
ReplyDeleteIs there a way to debug the webservices code particularly the server side API.
Great tutorial!!! Very nice and very well explained...
ReplyDeleteCheers!!!
jAY
Just Excellent. Thanks a lot!!
ReplyDeleteRavi: create web service client using jsp..
ReplyDeleteIt seems you are not asking the correct question. JSP is not a place to call a web service, you better write a java client using the WSDL file.
really nice work. it made my life simpler. thanks a lot -mathew
ReplyDeleteExcellent article!
ReplyDeleteJust a note to people who run into the null being retured to the client: everytime you do step 4 (generate server-side classes), you have to re-do step 5 (call implementation method from web service impl).
Thank U very much for the wonderful article which made my job easier.
ReplyDeletehi my question was to consume web services using jsp page..
ReplyDeletei am generated client proxy and packed the class files into jar files and using the jar files in my jsp...
Is that the correct way to do???
please give some inputs...
thanks and regrds
Ravi
Hi,
ReplyDeleteI tried doing the above steps by replacing the return type with my custom java class. That gives an "java.lang.reflect.InvocationTargetException" exception.
What changes (if any) do I need to make to replace the integer return type with user-defined java class?
Thanks
Hi Kamal
ReplyDeleteThanks for wonderful tutorial..
It has actully given us a new direction..
I've followed all this steps and all files are generated but while running client side java file an error is occurring..
Command Line details are:-
----------------------------------------------------
- Unable to find required classes (javax.activation.DataHandler and javax.mail.i
nternet.MimeMultipart). Attachment support is disabled.
15 + 6 = -3
15 - 6 = -3
-------------------------------------------------------
Please tell me the solution..
Really great tutorial man. U r doing a great service. This tutorial helped me a lot with ma work. Thanks
ReplyDeleteEverything is perfectly explained here. I saw few people having issue with version and few getting wrong results.
ReplyDeleteI think folowing should come at the end of step 5 not end of step 4.
Now we should compile those generated classes using the following command.
WS-Sample\src> javac –d ..\classes org\kamal\wssample\ws\generated\*.java
Thank you for the nice example. Would appreciate any advice on how to proceed with adding security? For example, requiring certificate on the client side, using HTTPS/SSL, encrypting contents?
ReplyDeleteThank you for the tutorial. Any advice on how to proceed with securing the web service, for example with HTTPS/SSL and requiring a client certificate?
ReplyDeletei'm not very good in java. when i try to do the compilation of the 5generated java files it generate an error saying
ReplyDeletejavac: invalid flag: ud
Usage: javac < option > < source files >
can u please help me to solve this. regards.
ps: nice tutorial. quite easy to understand
Hi Kamal thank you very much for Providing a good sample.
ReplyDeletereally it helped me a lot. i am new bie to Apache Axis.
dear kamal aiya,
ReplyDeletei hav a little bit advanced excercise. can i hav an opinion on it or good if you can start and give a complete guide to it. i have tried so many web articles but no good answer found yet. the exercise is as follows....
Exercises :
1) Develop customer profile web service as below: which having two methods saveCustomer and retrieveCustomer
Customer infomation data structure as follows
CustomerID :string
Name :string
phoneNumber : int
Address : Object which contain(home number(int), street(string), town(string))- Complex type object
Age: int
LastBalance: double
Ex1:
you send the SOAP request (in your web service call) with customer id or phone number the web service should return customer information and display as system out.
Note Just hard code customer dummy data inside web service method call getCustomerData which return the customer object.
Ex2
Compose customer object (java object) in client side and send via web service using web service save method to write to a data to text file in server side (in your case same machine , but it create by customer profile web service not the web service client)
Hi Kamal,
ReplyDeleteThanks a lot for sharing this material and it is very useful for me in learning webservices-Apache Axis (1.4). Please share us any information if you prepared on Axis 2.0
Regards,
Sarayu
Hi kamal,
ReplyDeleteI am still having a little problem. I managed to follow every step of the tutorial, except the last one, the actual test.
I allways get the stack wich you can find at the bottom.
Can you help me? Thx in advance
Tim
My classpath is as follows, and the jars are there in that folder:
C:\axis\axis.jar;C:\axis\commons-discovery-0.2.jar;C:\axis\commons-logging-1.0.4.jar;C:\axis\jaxrpc.jar;C:\axis\saaj.jar;C:\ax
is\wsdl4j-1.5.1.jar;C:\axis\log4j-1.2.8.jar;
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
org.apache cannot be resolved to a type
org.apache cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
The method getcalculator(URL) from the type CalculatorServiceLocator refers to the missing type ServiceException
javax.xml.rpc cannot be resolved to a type
The constructor CalculatorSoapBindingStub() refers to the missing type AxisFault
The method setPortName(String) is undefined for the type CalculatorSoapBindingStub
org.apache cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
The constructor CalculatorSoapBindingStub() refers to the missing type AxisFault
The method setPortName(String) is undefined for the type CalculatorSoapBindingStub
javax.xml.rpc cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
The method getPort(Class) from the type CalculatorServiceLocator refers to the missing type ServiceException
The method getcalculator() from the type CalculatorServiceLocator refers to the missing type ServiceException
The method getPort(Class) from the type CalculatorServiceLocator refers to the missing type ServiceException
org.apache.axis.client.Stub cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
javax.xml.rpc cannot be resolved to a type
The method setEndpointAddress(String, String) from the type CalculatorServiceLocator refers to the missing type ServiceException
at org.kamal.wssample.ws.generated.CalculatorServiceLocator.(CalculatorServiceLocator.java:10)
at org.kamal.wsclient.CalcClient.main(CalcClient.java:14)
Hi Sarayu, I'll try to prepare another tutorial with Axis 2.0.
ReplyDelete// Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ReplyDeleteCan you paste the command you are using to compile your classes?
Hey Kamal,
ReplyDeleteI used exact the command mentioned in the tutorial
I also tried it in Eclipse.
I suppose my problem is in the client jar file. should there be a reference to the jaxrpc.jar somewhere?
thx
Tim
As I have mentioned in the start, I was using jdk1.6 which includes these classes. If you are not using that, please try adding jaxrpc.jar into the classpath.
ReplyDeleteHi kamal,
ReplyDeletei have generated WSDL files using the port no 8090 like your suggestion only...
I am looking forward to your guidance.
dear kamal, i get an error in the 4th step when i try to run
ReplyDeleteWS-Sample\src> javac –d ..\classes
org\kamal\wssample\ws\generated\*.java
the error is
javac: invalid flag: ud
Usage: javac < option > < source files >
how to overcome this? waiting for your reply.
hi kamal,
ReplyDeletethis is regarding the previous post. this is the error.
D:\Web Service Files\WS-Sample\src>javac -d ..\classes org\ushan\wssample\ws\generated\Calculator.java
javac: invalid flag: ûd
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are u
sed
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
Hi mIsTiK cHaZeR,
ReplyDeleteTry replacing the "*.java" part with the correct named of the files.
same error comes when i compile the files separately. is this error connected to the classpath?
ReplyDeleteYes it is related to the classpath. Can you verify that your classpath is correct?
ReplyDeleteSET CLASSPATH=C:\axis-1_2_1\lib\activation.jar;.;C:\axis-1_2_1\lib\axis.jar;C:\axis-1_2_1\lib\axis-ant.jar;C:\axis-1_2_1\lib\jaxrpc.jar;C:\axis-1_2_1\lib\commons-discovery-0.2.jar;C:\axis-1_2_1\lib\commons-logging-1.0.4.jar;C:\axis-1_2_1\lib\wsdl4j-1.5.1.jar;C:\axis-1_2_1\lib\xalan-2.7.1.jar;C:\axis-1_2_1\lib\xercesImpl-2.9.1.jar;C:\axis-1_2_1\lib\xml-apis-1.3.04.jar;C:\axis-1_2_1\lib\mail.jar;C:\axis-1_2_1\lib\opensaml-1.1.jar;C:\axis-1_2_1\lib\wss4j.jar;C:\axis-1_2_1\lib\bcprov-ext-jdk15-140.jar;C:\axis-1_2_1\lib\bcprov-jdk15-140.jar;C:\axis-1_2_1\lib\xmlsec-1.4.0.jar;C:\axis-1_2_1\lib\log4j-1.2.8.jar;C:\axis-1_2_1\lib\saaj.jar;C:\axis-1_2_1\lib\xml-serializer-2.7.1
ReplyDeletethis is my classpath.
Are you facing this issue only when using the "javac" command for these classes? Can you create a sample java class in a package on your machine (not inside this project) and try to compile it?
ReplyDeleteI just noticed something in your classpath.
ReplyDeleteIt ends as;
....;C:\axis-1_2_1\lib\saaj.jar;C:\axis-1_2_1\lib\xml-serializer-2.7.1
The final jar file is not having the extension (xml-serializer-2.7.1.jar). Please correct that and try again.
yes i can compile java files in other packages. i corrected that error but no use. so i changed the directory and went inside D:\Web Service Files\WS-Sample\src\org\ushan\wssample\ws\generated and compiled the files and generated the .class files in the same directory and then copied them in to D:\Web Service Files\WS-Sample\classes\org\ushan\wssample\ws\generated. is that ok. when i was doing so i got this >>>
ReplyDeleteD:\Web Service Files\WS-Sample\src>cd org\ushan\wssample\ws\generated
D:\Web Service Files\WS-Sample\src\org\ushan\wssample\ws\generated>javac *.java
Note: CalculatorServiceLocator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D:\Web Service Files\WS-Sample\src\org\ushan\wssample\ws\generated>
You can ignore those warning messages, however that is not the way to compile classes inside packages.
ReplyDeleteI would suggest you to set the classpath explicitly inside command prompt with the required jar files and compile these classes from the src directory.
i retried the process. i guess now it's working. i got this same message same as above. this is ok rite??
ReplyDeleteD:\Web Service Files\WS-Sample\src>javac -d ..\classes org\ushan\wssample\ws\gen
erated\*.java
Note: org\ushan\wssample\ws\generated\CalculatorServiceLocator.java uses uncheck
ed or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D:\Web Service Files\WS-Sample\src>
Ok, so your issue was in the classpath variable (missing .jar).
ReplyDeleteYou can ignore those warning messages for now.
thanks kamal. this helped me a lot. i'll buzz u if there are any other issues that matters me. thanx again for the great help.
ReplyDeletedear kamal,
ReplyDeletei get the final out put of your tutorial successfully. it's really good and got a really nice understanding on web services. as i'm new to this topic i have more questions. is there a possible way to run this web service on a web browser and how to do that? and if i need to add two numbers which i like at the run time which files should i modify?
i hav to say more that i hav followed your tutorial using axis 1.2.1 tomcat 5.5 and jdk 1.5. it seems this guide works fine with these configurations too.
ReplyDeleteHi mIsTiK cHaZeR,
ReplyDelete// if i need to add two numbers which i like at the run time
You can use any number at the client side. As you can see from the CalcClient class, we pass the parameters to the web service in this class. So you only have to change the client class to pass runtime values.
Hi Kamal,
ReplyDeleteGetting an error at step 4: WSDL2Java - Generate server side and client side classes for web service
java -classpath "D:/lib/axis.jar;D:/lib/commons-discovery-0.2.jar;D:/lib/commons-logging-1.0.4.jar;D:/lib/jaxrpc.j
ar;D:/lib/log4j-1.2.8.jar;D:/lib/saaj.jar;D:/lib/wsdl4j-1.5.1.jar;D:/lib/axis-ant.jar;D:/lib/activation.jar;D:/lib/mail.jar;."
org.apache.axis.wsdl.Java2WSDL
-o src
-p sample.ws.generated
-s
calculator.wsdl
Error: Unable to parse first argument for option -p
Java2WSDL emitter
Usage: java org.apache.axis.wsdl.Java2WSDL [options] class-of-portType
What I am missing here?
Thank you
Figured it out: wrong tool
ReplyDeleteinstead of Java2WSD should be WSDL2Java
Hi,
ReplyDeleteI get the following error:
java.lang.ClassNotFoundException: org.kamal.wssample.ws.Calculator
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:161)
at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)
at org.apache.axis.wsdl.fromJava.Emitter.setCls(Emitter.java:2079)
at org.apache.axis.wsdl.Java2WSDL.run(Java2WSDL.java:584)
at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:682)
My CLASSPATH includes all required libraries:
/usr/share/java/axis/axis.jar:/usr/share/java/commons-discovery.jar:/usr/share/java/commons-logging.jar:/usr/share/java/axis/jaxrpc.jar:/usr/share/java/log4j.jar:/usr/share/java/axis/saaj.jar:/usr/share/java/wsdl4j.jar
and I have replicated the directory strucutre exaclty as described in the article. Ijust do not know, how to get over this problem.
I also tried to strace and ltrace the compilation. strace gives very little information. I do not see any attempt to touch the file whatsoever. ltrace end with "+++ killed by SIGTRAP +++". Total confusion on my side.
It turned out theat I did not have my current directory "." in my CLASSPATH, therefore the java2wsdl tool was not able to load the Calculator class.
ReplyDeleteI ran into another problem - I could not deploy the service, because AdminService was not found. The reason was I installed Axis version 1.4.1 instead of Axis version 1.4, which is ni fact version 2.0. Very confusing. I spent several hours figuring out what went wrong. I could not understand the the AdminService just was not there.
After this the example worked without any problem. An excelent tutorial. I am a complete newbie to web services.
Just one remark - CalculatorSoapBindingImpl (step 5) has to be edited before compilation in step 4 takes place. Steps 4 and 5 have to be rearranged in the following way:
A. generate server side and client side classes for web service
B. bind Web service with Functionality provider
C. compile
I have nothing else to add. Great work. Thank you very much.
This is really Ultimate tutorial for the beginner.Thanks a lot for providing such good tutorial
ReplyDeleteKumar Saurabh
Great article, Kamal.
ReplyDeleteFollowing your instructions, I got the expected results. But there's one thing unclear to me.
After making changes to CalculatorSoapBindingImpl.java to bind SimpleCalculator to the web service, you did not compile the changed file. And yet. somehow, the web service worked. I redid the entire procedure a couple of times, and it worked every time.
So, how does it work exactly that you don't have to compile CalculatorSoapBindingImpl.java and the web service can find the binding to SimpleCalculator class?
Hi Kamal,
ReplyDeleteThis is a very useful tutorial for the beginners.
I am developing a client to a certain webservice. I have the wsdl with me. I generated the java classes using wsdl2java. Using the methods of service object, I am able to communicate with the webservice and I am getting the response objects. Everything is fine but for logging purpose, I want the soap request and response xml messages.
I am new to axis and unable to find a way to get those xmls. Some suggested to use TCPMON but I want something which can work within my coding and I can save the request and response xmls.
Can you please state one example on how to achieve it?
Thanks in advance.
____
Raju
Hi Kamal
ReplyDeleteNice article. I successfully completed it, now I wish to create on more function in the calculator class which accepts an Equation object (POJO) like following:
---------------------------
public interface Calculator {
int calculate(Equation equation);
int add (int x, int y);
int subtract(int x, int y);
}
--------------------------------
Following is Equation's code:
public class Equation {
private int leftOpr;
private int rightOpr;
private String operator;
public int getLeftOpr() {
return leftOpr;
}
public void setLeftOpr(int leftOpr) {
this.leftOpr = leftOpr;
}
public int getRightOpr() {
return rightOpr;
}
public void setRightOpr(int rightOpr) {
this.rightOpr = rightOpr;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
-----------------------------------
I placed equation in package org.kamal.wssample. But when I tried to bind the method in the binder class like this:
public int calculate(org.kamal.wssample.ws.generated.Equation in0) throws java.rmi.RemoteException {
return calc.calculate(in0);
}
it's showing error in return line : The method calculate(Equation) in the type SimpleCalculator is not applicable for the arguments (Equation)
I observed that this is because the calculate function in the bindingImpl class is declared with argument type : org.kamal.wssample.ws.generated.Equation while the SimpleCalculator's calculate function accepts:org.kamal.wssample.Equation.
I tried creating an interface for Equation class and using it to implement a baseEquation but still it's not working.
So basically my question is: How to pass complex objects as arguments to a web service method. Can you please help? or give reference to some doc/book?
Thanks & Regards
Arun Raj
Hey, Kamal, its realy kamaaal.
ReplyDeletethis post is realy hlpful for the people like me, the beginners.
kp doing the gud job.
thnx for the article
Hi Kamal, thank you very much for the article
ReplyDeleteI am new to this and want some help.
I want to get the soap request and response xmls which are sent and received by my axis client. I want these xmls for the logging purpose. Can you please suggest me how to get them?
It will be of much help.
Thanking you
Raju
Great job man, keep it up.
ReplyDeleteI guess you are not able to solve my requested problem. No problem.
ReplyDeleteThanks and Regards,
Raju
This is really very good tutorial. I've seen many tutorials but no one mention clearly.
ReplyDeleteHI KAMAL
ReplyDeleteTHANKS FOR THIS TUTORIAL. IT HELPED US A LOT IN COMPLETING OUR MAJOR PROJECT WEBSERVICES.THE ONLY PROBLEM WE GOT IS WITH DATABASE CONNECTIVITY BUT LATER ON WE SOLVED IT WITH ORACLE DRIVER.
Hi Kamal,
ReplyDeleteFirst of all many thanks for writing such an easy to understand article. I have two questions related to my project work.
1) Although a bad design, the project I work on does not seem to be having any interface (like Calculator.java created in step 2) to the service class implementation. Is it possible to continue with step 3 and further without doing step 2. Seems possible to me, although not a good design. Just wanted to clarify with you.
2) This one is more baffling to me and I seriously need your help. I don't find any kind SoapBindingImpl. java class being used. Is it possible for a client to access the service directly (client is in .net, not in java) without the use of binding class. I don't even see the stub being used either. I mean I don't find it in the project. I only see deploy.wsdd and undeploy.wsdd.
It is confusing, but are there any steps that are not mandatory in the article. Even though skipping some of these steps would promote bad design, I just wanted to know how the project might be working. Please let me know which steps are absolutely mandatory so that I try to relate those with my project work. Thanks a lot in advance. Your help is greatly appreciated.
PLS REPLY AS SOON AS POSSIBLE !!!
ReplyDeleteHi Kamal,
Thanks for your tutorial. It is helping me ...
On this step I am getting the exception on the browser
AXIS error
Sorry, something seems to have gone wrong... here are the details:
Fault - ; nested exception is:
org.apache.axis.ConfigurationException: Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
Hint: you may need to copy your class files/tree into the right location (which depends on the servlet system you are using).; nested exception is:
java.lang.ClassNotFoundException: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
Hint: you may need to copy your class files/tree into the right location (which depends on the servlet system you are using).; nested exception is:
java.lang.ClassNotFoundException: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:cpltn84qvsb
Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
Hint: you may need to copy your class files/tree into the right location (which depends on the servlet system you are using).; nested exception is:
java.lang.ClassNotFoundException: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
at org.apache.axis.providers.java.JavaProvider.getServiceClass(JavaProvider.java:432)
at org.apache.axis.providers.java.JavaProvider.initServiceDesc(JavaProvider.java:461)
at org.apache.axis.handlers.soap.SOAPService.getInitializedServiceDesc(SOAPService.java:286)
at org.apache.axis.deployment.wsdd.WSDDService.makeNewInstance(WSDDService.java:500)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployableItem.java:274)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableItem.java:260)
at org.apache.axis.deployment.wsdd.WSDDDeployment.getService(WSDDDeployment.java:427)
at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:231)
Please help me. Also please let me know is it possible to include xsd validations in the wsdl ??? thanks in advance ... eagerly waiting for ur reply... Pls reply soon ...
For:
ReplyDeleteorg.apache.axis.ConfigurationException: Could not find class for the service named: org.sample.wssample.ws.generated.CalculatorSoapBindingImpl
It seems either you have changed the package structure or using incorrect package named, according to the originally package names following should be the correct name.
org.kamal.wssample.ws.generated.CalculatorSoapBindingImpl
If you have changed it, please check other locations that you haven't changed.
Very Nice , Clear and Greate Work.Thank You - Rajesh Kumar Raj
ReplyDeleteHi Kamal,
ReplyDeleteI am new with implementing WebServices with Axis. On reading your article I have few questions which is pretty not clear for me, can you please help me out with the following questions?
1) In the 3rd step, you have mentioned the interface class alone to create the wsdl file and nowhere you havent mentioned the actual class, i.e SimpleCalculator.java when creating the wsdl file
2) Then in the 4th step you perform the wsdl2java, in that you mention the wsdl file alone to create client and server side code to deploy and invoke the webservice.
3) After doing wsdl2java, you get five automatically generated java classes. Out of which, in CalculatorSoapBindingImpl.java class how do you get the following line included?
private SimpleCalculator calc = new SimpleCalculator().....
and hows this possible? Because you havent mentioned of SimpleCalculator.java anywhere when creating the wsdl file or wsdl2java operation.
Thanks for your swift reply.
ReplyDeleteI am developing a small project which will help us to test the main application. To develop that I got a wsdl and xsd from them. I have installed all the below s/W,
1. Jdk1.5
2. Tomcat 6.0
3. Apache Axis 1.4
4. SOAP UI (instead of client)
From given wsdl, I have generated server side classes (like stub, skeleton, other java classes and wsdd) by using wsdl2java tool. Then added all the compiled classes in the web-inf folder and deploy the service by using admin client tool.
Now I am able to see the service in the axis service list page. From there I got a wsdl file and I am planning to use soapUI as client to test this project.Now if I use this wsdl (system generated) in soapUI client. It is throwing null pointer exception where as that wsdl (client provided) is not. I found the diff between the 2 version of wsdl.
Continuing in the next comment.
Great tutorial bhai. This was very useful to revise my Axis knowledge in less then 10 minutes and prepare for interview. Reading documents takes way too much time and this is what I needed.
ReplyDelete-Madhu
Hi,
ReplyDeletewhile executing the web service client pgm( java -cp %CLASSPATH%;.;..\lib\calculatorClientSide.jar org.kamal.wsclient.CalcClient ), i got the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/kamal/wsclient/CalcClient
Caused by: java.lang.ClassNotFoundException: org.kamal.wsclient.CalcClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.kamal.wsclient.CalcClient. Program will exit.
please help me
Thanks in advance..
Nithya
Thanks a lot Kamal, this is excellent tutorial for newbies.
ReplyDeleteI am wondering if you can provide a way to for web clients to access the services.
For example a form to access this service.
I believe web services is for web clients most of the time.
Thank you.
// Anonymous (August 10, 2009 9:00 AM)
ReplyDelete// private SimpleCalculator calc = new SimpleCalculator().....
// and hows this possible? Because you havent mentioned of SimpleCalculator.java anywhere when creating the wsdl file or wsdl2java operation.
In Step 5: I have mentioned this; you are editing the generated BindingImpl class to delegate all method calls to this SimpleCalculator class.
// Nithya (September 24, 2009 3:10 PM)
ReplyDelete// Exception in thread "main" java.lang.NoClassDefFoundError: org/kamal/wsclient/CalcClient
Caused by: java.lang.ClassNotFoundException: org.kamal.wsclient.CalcClient
Hi Nithya,
This is simply a classpath error; runtime could not find the CalcClient class. Please correct the classpath error and try again.
Are you running this command from "classes" folder of the project?
// 130. Anonymous (October 03, 2009 3:57 AM)
ReplyDelete// I am wondering if you can provide a way to for web clients to access the services.
If you are trying to use the web services with a web application; you can use a Servlet to act as a client to your web services.
It is a very good tutorial for a beginner. Thank you very much Kamal for your effort. Keep it up! All the best!
ReplyDelete-Harihar
Hi Kamal,
ReplyDeleteDo you know where should I look? for resolving the conflict, as describe at post #131
Hi Kamal,
ReplyDeleteShould we run the AdminClient to register webservice from the same machine where we are hosting webservices or can we run it remotely also ? Please advice, Thanks.
Great Tutorial, one minor change required though. We need to customize the server Side classes BEFORE compiling them. This issue has also been mentioned by someone else( in comment number 113) and I quote that person again since the changes proposed by him have not yet materialized.Here it goes.
ReplyDelete"CalculatorSoapBindingImpl (step 5) has to be edited before compilation in step 4 takes place. Steps 4 and 5 have to be rearranged in the following way:
A. generate server side and client side classes for web service
B. bind Web service with Functionality provider
C. compile"
Thanks again for a great tutorial
Ahsun Taqveem
Hi Kamal,
ReplyDeleteI am new to web services and trying to use services from 3rd party. I have all jars required to consume those services and it is working on weblogic 9.2 with Axis 1.4 jars. Now we are migrating to weblogic 10.3, else every thing is same. I have put all axis jars in startweblogic script classpath but getting error as
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis.configuration.FileProvider
please suggest why it is not finding axis.jar ? is there any incompetibility with weblogic 10.3? PLease reply ASAP as i am stuck beacause of this issue.
Thanks in advance.
Hi,
ReplyDeleteI am new in web services, I go through the above said way
but I am getting an error when I am running the command
C:\workspace\WS Sample>java org.apache.axis.wsdl.WSDL2Java -o src -p org.kamal.wssample.ws.generated -s calculator.wsdl
I am getting an error like
java.net.MalformedURLException: no protocol: calculator.wsdl
at java.net.URL."init"(URL.java:567)
at java.net.URL."init"(URL.java:464)
at java.net.URL."init"(URL.java:413)
at weblogic.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:8
at weblogic.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManage
at weblogic.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentSca
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at weblogic.apache.xerces.parsers.DOMParser.parse(DOMParser.java:257)
at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:2
at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:149
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)
Please help me.Thanks in advance.
Hi
ReplyDeleteI am new in web services,I am getting an error when I am executing dos command on point 4 as
C:\workspace\WS Sample>java org.apache.axis.wsdl.WSDL2Java -o src -p org.kamal.wssample.ws.generated -s calculator.wsdl
I am getting the following error
java.net.MalformedURLException: no protocol: calculator.wsdl
at java.net.URL.init(URL.java:567)
at java.net.URL.init(URL.java:464)
at java.net.URL.init(URL.java:413)
at weblogic.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:836)
at weblogic.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java
at weblogic.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerIm
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
at weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at weblogic.apache.xerces.parsers.DOMParser.parse(DOMParser.java:257)
at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201)
at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:149)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)
Please help me.Thanks in Advance
Hi Kamal,
ReplyDeleteI go through your tutorials and run the web services.Initially I found some issue in making the server side as well as Client side java core generation.But finally I run the application.It really a nice tutorials for the new Web services developer.
It will be nice if you add the tutorials for the Apache Axis2.It really a nice work.Thanks a lot.
Thanks
Chhote
thank you. you did a great job. Very easy to understand and nice tutorial,
ReplyDeleteThank,
Srikanth G
I tried to generate WSDL from java file using RAD7.0 run command and by passing the required arguments as mentioned, but I am getting the following error
ReplyDeleteThe java class is not found: javax.xml.rpc.encoding.TypeMappingRegistry
Can you please suggest.
Hi Kamal,
ReplyDeletei am getting above error after running below java2WSDL statement at command prompt:
" Unrecognized Option: -o
Could not create the Java virtual machine "
java org.apache.axis.wsdl.Java2WSDL
-o ..\calculator.wsdl
-n urn:org.kamal.calculator
-l http://localhost:8080/axis/services/calculator
org.kamal.wssample.ws.C alculator
Could please help me on this...?
// 149 Anonymous
ReplyDeleteYou need to enter the complete command in one line, even though I have shown each option in separate line.
Hi Kamal,
ReplyDeleteRegarding 149 issue,
Thanks for your response.
Actually i tried complete statement in the same line only. Eventhough i got below error .
"Unrecognized Option: -o
Could not create the Java Virtual machine"
Even i just tried with "java -classpath org.apache.axis.wsdl.Java2WSDL -o" at command line. Then also i got same error.
I have the all jar files in class path.
It seems command prompt is not able to find Java2WSDL class.
is there any clue please?
Thanks,
Vijay
// 149
ReplyDeletejava org.apache.axis.wsdl.Java2WSDL
Can you try the above command and see whether it displays the options list. If the options list is not shown, then there's a classpath issue.
Or else I doubt this is happening due to a typo. Please try adding one option at a time and see where you encounter the issue.
Kamal,
ReplyDeleteReg 149,
Thank you very much for your valuable support.
Its due to classpath issues only.
I used environment variable as just "Path" instead of "CLASSPATH".
Now, this Java2WSDL statmement has executed well.
Thanks,
Vijay
Hi Kamal,
ReplyDeleteI am geeting a soap fault response like "ws security header missing".
I need to pass the UsernameToken header in the request. I generated the client side jar using axis and wrriten a client to call the services by using the generated classes. But it is expecting a security header in the request. I am newbie to webservice. I am not sure how to pass the ws security header through my client program as I didnt have any stub class to provide a username to the service calss. Please help me to resolve this..
i asked some question about web serivce and select the comment as google account????thinking that it would ask my gmail id but i don;t where it went.
ReplyDeletePlease help
I'm new to Web service and your tutorial helped me a log to get started in Webservices.
ReplyDeleteI was able to run through your tutorial which brought me some question.
Can we create our own web application and register one of its classes as Web service?That is instead of copying the class file into the webapps/axis/WEB-INF classes webapps/MyWebApp/Web-INF..?
Please explain the steps.
Wonderful work!! I really appreicate this. Indeed I developed my first web service with your help!! Thanks again
ReplyDeleteKARTHIK
Related to my previous post 157. When I do copy my classes from calculatorServerSide.jar into %AXIS_HOME%\WEB-INF\classes it works fine !!
ReplyDeleteBut it can't find the classes in jar file which located in %AXIS_HOME%\WEB-INF\lib
What is wrong?
Thanks,
-Vit
Hi Kamal, congratulations by your excelent work.
ReplyDeleteI'm having a problem, my result is :
15 + 6 = -3
15 – 6 = -3
My CalculatorSoapBindingImpl.java :
package org.kamal.wssample.ws.generated;
public class CalculatorSoapBindingImpl implements org.kamal.wssample.ws.generated.Calculator{
public int add(int in0, int in1) throws java.rmi.RemoteException {
return calc.add(in0,in1);
}
public int subtract(int in0, int in1) throws java.rmi.RemoteException {
return calc.subtract(in0,in1);
}
}
Please, Kamal, i need your help, thanks.
Best Regards, Valter Henrique.
Dear Valter Henrique
ReplyDeleteLooks like your binding class is not compiled after coupling with original class, hence results are -3
in wich step, of the tutorial says to compile the binding class?
ReplyDeleteBecausa i do everything, what kamal says,but maybe i'm missing this step,unfortunately.
Thanks 161.
thanks
ReplyDeleteThanks Kamal! Your tutorial really helps me to learn how to create a web service using Apache Axis. I searched through the Internet for tutorials but yours is the best!
ReplyDeleteRegina
I would like to deploy this webservice on weblogic 8.1, instead of tomcat. Can you please mention the steps for the same?..........Santosh Aherkar (santosh.aherkar@gmail.com)
ReplyDeleteHi kamal,
ReplyDeleteI am trying to invoke a web service inside another web service and encountering errors. I am using axis1.4, Tomcat 6. Is it possible to do this ? I would really appreciate if could provide me some starting point on this.
--
Esh
Hi, my webservice returns an array of javax.activation.DataHandler but when I generate the wsdl file using jva2wsdl...the wsdl file is generated in error... it gives some schema related error. Can anyone help on this issue...
ReplyDeleteThanks
Parul
Kamal Mettananda,
ReplyDeleteThis is an awesome article, step-by-step, simple and easy to remember.
Keep up the good work.
Cheers!
Daniel Suarez Jabonete
Pragmatic Developer
Philippines
This is an excellent startup tutorial
ReplyDeleteHi Kamal,
ReplyDeleteIt's really gr8. I am new in web service. And wana learn since past few month. But I did not got anything. But now I got you tutorial. I did every thing and now I m satisfy.
I am getting an error. When I am going to deploy it. I changed the port to 8090. But still getting same error.
********************************************
d:\WS-Sample\src>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\g
enerated\deploy.wsdd
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectR
esourceBundle).
log4j:WARN Please initialize the log4j system properly.
Processing file org\kamal\wssample\ws\generated\deploy.wsdd
Exception: AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (404)Not Found
faultActor:
faultNode:
faultDetail:
{}:return code: 404
<html><head><title>Apache Tomcat/6.0.26 - Error report</tit
le><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;ba
ckground-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;
color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Ari
al,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-f
amily:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-famil
y:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:
Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color :
black;}A.name {color : black;}HR {color : #525D76;}--></style> </hea
d><body><h1>HTTP Status 404 - /axis/services/AdminService</h1&
gt;<HR size="1" noshade="noshade"><p><b>ty
pe</b> Status report</p><p><b>message</b> <u>
;/axis/services/AdminService</u></p><p><b>description<
;/b> <u>The requested resource (/axis/services/AdminService) is not ava
ilable.</u></p><HR size="1" noshade="noshade"
><h3>Apache Tomcat/6.0.26</h3></body></html>
{http://xml.apache.org/axis/}HttpErrorCode:404
*******************************************************
Is there I am missing somthing.
Thanks,
Vinay
problem in creating wsdl..
ReplyDeleteException in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/
Java2WSDL
plz help..
THank you very much for this excellent tutorial...
ReplyDeleteAm getting the following exception,can you please help me out?
ReplyDeleteException in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl
Java2WSDL
Caused by: java.lang.ClassNotFoundException: org.apache.axis.wsdl.Java2WSDL
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.apache.axis.wsdl.Java2WSDL. Program will ex
t.
Exception: AxisFault
ReplyDeletefaultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (404)Not found
faultActor:
faultNode:
faultDetail:
{}:return code: 404
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not found</TITLE>
</HEAD><BODY><H1>Not found</H1>
The requested URL /axis/services/AdminService was not found on this server</B
ODY></HTML>
{http://xml.apache.org/axis/}HttpErrorCode:404
Hi and thanx for the tutorial. I have a problem though running teh Java2WSDL command. I get the following error about :
ReplyDeleteUsage: java org.apache.axis.wsdl.Java2WSDL [options] class-of-portType
Options:
-h, --help
print this message and exit
-I, --input
input WSDL filename
-o, --output
output WSDL filename
... etc
This is my command:
java org.apache.axis.wsdl.Java2WSDL
-o ..\calculator.wsdl
-n urn:org.kamal.calculator
-l http://localhost:8080/axis/services/calculator
org.kamal.wssample.ws.Calculator
What I am missing?
Daniel
renaming xerces-1.4.4.jar to xerces.jar worked in the lib directory of ur class path worked for me
ReplyDeletei want to implement the above with web logic 8.1 .so what changes needs to be done in the above tutorial. I tried the same with weblogic but it is not working.when i type this command java org.apache.axis.client.AdminClient it gives me error java.lang.noClassDefFound exception. i added the above jars in classpath also.please help me to implement this tutorial in web logic.
ReplyDeletethanks in advance.
I had never worked on WS earlier.
ReplyDeleteThis gives a clear understanding of what are Web Services are.
Good article and good example.
Thanks
-Ananymous.
Hi Kamal,
ReplyDeleteThanks so much for your useful tutorial.
I have a little question:
Everything went fine till I run the client, it is returing '-3' as a result and the following error:
Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
15 + 6 = -3
15 - 6 = -3
Can you help with that please.
Jaxrpc.jer is in the classpath
Many thanks for your precious help.
Solution:
ReplyDelete--------
It was to do step 5.
The problem is that most readers do not notice that step 5 is about to ADD the 2 lines of code into the existing class 'CalculatorSoapBindingImpl' .
return calc.add(a, b);
return calc.substract(a,b):
In the tutorial it is not explicit :) it emphasis the fact that the reader should ANALYSE the code :)
Thanks for the tutorial!
// 186. Mohamed
ReplyDeleteAs always a watchful learning will teach you a lot.
Hi,
ReplyDeletevery nice tutorial.
I have deployed tomcat 5.5 and axis 1.4 on windows 7, using java 6 update 23.
Although I seemed to follow all instructions the axis webapp just won't get deployed. Instead on the tomcat startup screen I get an "error listenerStart" message and the axis validation screen on the web browser does not appear. Any suggestions? thanks
Hi Kamal,
ReplyDeleteSorry for bothering you with my last question. please ignore that. I have tested the web-servies using XML-SPY. it is working perfectly fine.
My another question is, how i can use oracle packages inside the web-service java files.
Basicaly, i would like to know, at which place i should expose my connection details of oracle. is there some standadd way?
Regards
Sushil
Hi ,
ReplyDeleteHow to change the package name of the web service client generated files .
my wsdl file contains namespace with the space i.e like this (TM%20IO%20Asset%20No%20Hie)
so when i convert wsdl to java package name will be "TM IO Asset No Hie" .
so files are not getting complied .i changed the package name manually .
but when i try to create an object i am getting following exception
java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlComplexContentImpl
By this command i am generating the files
sh "$dir"/axis2.sh org.apache.axis2.wsdl.WSDL2Java -uri /home/rashmi/Project/sample/axis2-1.5/bin/FTGetAssetDetail.wsdl -l java -d xmlbeans -p com.siebel.www.xml.assetdetails -o assetdetails
i am using with option xmlbeans . even the xml beans package was "TM IO Asset No Hie" i changed this manually
i am not sure should be compile the xml beans after this ?
excellent article...very well written!
ReplyDeleteExcellent post! Thank you very much!
ReplyDeleteHi Kamal,
ReplyDeleteA well written simple article, proved the right starting point for me.
Thanks,
Ziby
excellent article! easy to undestand...
ReplyDeletea point to notice is at step 5 there is the need to
modify the code and compile this code again. Thanks.
Hi,
ReplyDeleteThis is yaswanth, I am new to webservices and seeing this portal i am able to work fine but i am strucked at a point of 7 please help me ASAP
Exception: AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (404)Not Found
faultActor:
faultNode:
faultDetail:
{}:return code: 404
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Spiceworks, Inc." />
<title>Spiceworks Application Error</title>
<link href="/stylesheets/framework.css" rel="Stylesheet" type="text/css" />
<link href="/stylesheets/general.css" rel="Stylesheet" type="text/css" />
<!--[if IE]>
<style type="text/css">
h1.logo{
margin-top:15px
}
</style>
<![endif]-->
</head>
<body class="server_error">
<div id="container">
<h1 class="logo"><img alt="Spiceworks, Inc." src="/images/logos/small.png" bord
er="0" /></h1>
<h1>Page Not Found</h1>
<p>The page you were looking for could not be found, <a href="/">please go to the Spiceworks mai
n page</a> and try to find the page you
are looking for by navigating to it through the Spiceworks application.</p>
<p>We apologize for any inconvenience this may have caused you.</p>
<p>Please contact our support staff at <a href="mailto:support@spiceworks.com">support@spicework
s.com</a> if you continue to see this page.</p>
<p>For help using Spiceworks, please see <a href="http://help.spiceworks.com">Spiceworks Help<
;/a>.</p>
</div>
</body>
</html>
{http://xml.apache.org/axis/}HttpErrorCode:404
awesome.....
ReplyDeleteHi Kamal,
ReplyDeleteThanks for the tutorial. I got stuck at step 3 where you compile to get WSDL from java code. Can you tell me what's the errors are about?
Exception in thread "main" java.lang.NoClassDefFoundError:
org.apache.commons.logging.LogFactory
at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:45)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.(LogFactory.java:33)
at org.apache.axis.i18n.ProjectResourceBundle.(ProjectResourceBundle.java:53)
at org.apache.axis.i18n.MessagesConstants.(MessagesConstants.java:32)
at org.apache.axis.utils.Messages.(Messages.java:36)
at org.apache.axis.wsdl.Java2WSDL.(Java2WSDL.java:133)
at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:680)
thanks,
farid
Hi Kamal,
ReplyDeleteI have a question regarding the Web Service Client step. When I compile the web service client, I got this message:
C:\WS-Sample-Client\src>javac -classpath %CLASSPATH%;..\lib\calculatorClientSide
.jar -d ..\classes org\kamal\wsclient\CalcClient.java
javac: invalid flag: %AXIS_CLASSPATH%;.;c:\axis\lib\activation.jar;c:\axis\lib\axis.jar;c:\axis\lib\axis-ant.jar;c:\axis\lib\commons-discovery-0.2.jar;c:\axis\lib\commons-logging-1.0.4.jar;c:\axis\lib\jaxrpc.jar;c:\axis\lib\log4j-1.2.8.jar;c:\axis\lib\mail.jar;c:\axis\lib\saaj.jar;c:\axis\lib\wsdl4j-1.5.1.jar;c:\axis\lib\xercesImpl.jar;..\lib\calculatorClientSide.jar
Usage: javac
use -help for a list of possible options
When I removed the classpath, I got this message:
C:\WS-Sample-Client\src>javac -classpath ..\lib\calculatorClientSide.jar -d ..\c
lasses org\kamal\wsclient\CalcClient.java
org\kamal\wsclient\CalcClient.java:10: cannot access org.apache.axis.client.Serv
ice class file for org.apache.axis.client.Service not found
CalculatorService service = new CalculatorServiceLocator();
^
org\kamal\wsclient\CalcClient.java:11: cannot access javax.xml.rpc.Service
class file for javax.xml.rpc.Service not found
Calculator calc = service.getcalculator();
^
2 errors
Am I missing any step here?
Thanks
Hi Kamal,
ReplyDeleteI have a question regarding the Web Service Client step. When I compile the web service client, I got this message:
C:\WS-Sample-Client\src>javac -classpath %CLASSPATH%;..\lib\calculatorClientSide
.jar -d ..\classes org\kamal\wsclient\CalcClient.java
javac: invalid flag: %AXIS_CLASSPATH%;.;c:\axis\lib\activation.jar;c:\axis\lib\axis.jar;c:\axis\lib\axis-ant.jar;c:\axis\lib\commons-discovery-0.2.jar;c:\axis\lib\commons-logging-1.0.4.jar;c:\axis\lib\jaxrpc.jar;c:\axis\lib\log4j-1.2.8.jar;c:\axis\lib\mail.jar;c:\axis\lib\saaj.jar;c:\axis\lib\wsdl4j-1.5.1.jar;c:\axis\lib\xercesImpl.jar;..\lib\calculatorClientSide.jar
Usage: javac
use -help for a list of possible options
When I removed the classpath, I got this message:
C:\WS-Sample-Client\src>javac -classpath ..\lib\calculatorClientSide.jar -d ..\c
lasses org\kamal\wsclient\CalcClient.java
org\kamal\wsclient\CalcClient.java:10: cannot access org.apache.axis.client.Serv
ice class file for org.apache.axis.client.Service not found
CalculatorService service = new CalculatorServiceLocator();
^
org\kamal\wsclient\CalcClient.java:11: cannot access javax.xml.rpc.Service
class file for javax.xml.rpc.Service not found
Calculator calc = service.getcalculator();
^
2 errors
Am I missing any step here?
Thanks
Hi Kamal,
ReplyDeleteI have a question regarding the Web Service Client step. When I compile the web service client, I got this message:
C:\WS-Sample-Client\src>javac -classpath %CLASSPATH%;..\lib\calculatorClientSide
.jar -d ..\classes org\kamal\wsclient\CalcClient.java
javac: invalid flag: %AXIS_CLASSPATH%;.;c:\axis\lib\activation.jar;c:\axis\lib\axis.jar;c:\axis\lib\axis-ant.jar;c:\axis\lib\commons-discovery-0.2.jar;c:\axis\lib\commons-logging-1.0.4.jar;c:\axis\lib\jaxrpc.jar;c:\axis\lib\log4j-1.2.8.jar;c:\axis\lib\mail.jar;c:\axis\lib\saaj.jar;c:\axis\lib\wsdl4j-1.5.1.jar;c:\axis\lib\xercesImpl.jar;..\lib\calculatorClientSide.jar
Usage: javac
use -help for a list of possible options
When I removed the classpath, I got this message:
C:\WS-Sample-Client\src>javac -classpath ..\lib\calculatorClientSide.jar -d ..\c
lasses org\kamal\wsclient\CalcClient.java
org\kamal\wsclient\CalcClient.java:10: cannot access org.apache.axis.client.Serv
ice class file for org.apache.axis.client.Service not found
CalculatorService service = new CalculatorServiceLocator();
^
org\kamal\wsclient\CalcClient.java:11: cannot access javax.xml.rpc.Service
class file for javax.xml.rpc.Service not found
Calculator calc = service.getcalculator();
^
2 errors
Am I missing any step here?
Thanks
Thanks Kamal. A simple wonderful example.. This helped me a lot.
ReplyDeleteI have a query here on creating and using Skeleton.
Generally we will have Stub and Skeleton classes right ?
i.e Stub will be used in client side and Skeleton is for server side.
In our example we have created Stub class. But no Skeleton created.. Could you please let me know how I could create a Skeleton and how it will be used in our code ?
TIA
Rajesh (coool.dude.80@gmail.com)
Thanks Kamal for the simple wonderful example.
ReplyDeleteI have a query on using Skeleton in our example
Generally we will have Stub and Skeleton right ?
Stub will be in client side code and Skeleton will be used in Server side.
When a method is invoked using stub it will send the query to remote object using Skeleton.
Could you please help me understand on how can we use Skeleton in our example ?
TIA
Rajesh
Hi Kamal,
ReplyDeleteThanks a lot for the information. But it would be a great help if you can give more information(tutorial like this will be really help full like a enhancement for this would help us to understand the concept) about the usage of JAXB bindings. When it comes to large applications the mentioned modification in the step 5 will be a issue since it has to done manually each time.Is there any possibility of doing this rather than modifying the java sources in between the steps.Please help me on this. I have seen in large applications it just build the java sources using ant and it will not involve any source modifications in between.
Thanks,
Sampath
Really good work.. Thanks for posting..
ReplyDeleteExcellent tutorial . Keep posting tutorials.God Bless you..
ReplyDeleteHello,
ReplyDeleteThis is a great article on how to create web services. Explains every thing in a very simple manner.
It would be great if you could write an article on how all the generated files work together to complete the task.
Thanks.
very good... no problems getting it to work.
ReplyDeleteremember .. axis 1.4 is final and no longer supported.
I suggest people should use the standard java way using JAX-WS 2.0.
Fantastic explanation for web service learning people. Thanks a lot kamal.
ReplyDeleteIn the class path we have to add activation.jar and mail.jar additionally. Simple steps. Very nice
good explanation
ReplyDeleteSuperb
ReplyDeleteHi,
ReplyDeleteCan you provide the tutorial on How to consume multiple web services by a single client.
Hi Kamal,
ReplyDeleteThanks for writing such a beautiful blog. It is very comprehensive for newbies. I would like you to write blog for J2EE for newbies. It will be highly appreciated.
Regards
Howdy Kamal,
ReplyDeleteCan you please help me out with this ?
I am trying to generate WSDL file by the below command :
E:\Java Programs\WS-Sample\classes>java org.apache.axis.wsdl.Java2WSDL -o ..\cal
culator -n urn:org.ravi.calculator -l http://localhost:8080/axis/services/calcul
ator org.ravi.wssample.ws.Calculator
It spits error :
Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.lo
gging.LogFactory
at org.apache.axis.components.logger.LogFactory.class$(LogFactory.java:4
5)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45
)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory
.java:41)
at org.apache.axis.components.logger.LogFactory.(LogFactory.java
:33)
at org.apache.axis.i18n.ProjectResourceBundle.(ProjectResourceBu
ndle.java:53)
at org.apache.axis.i18n.MessagesConstants.(MessagesConstants.jav
a:32)
at org.apache.axis.utils.Messages.(Messages.java:36)
at org.apache.axis.wsdl.Java2WSDL.(Java2WSDL.java:133)
at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:680)
My Classpath variable is :
E:\Java Programs\WS-Sample\classes>echo %CLASSPATH%
C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.32\lib\servlet-api
.jar;E:\Softies\axis-bin-1_4\axis-1_4\lib\axis.jar;E:\Softies\axis-bin-1_4\axis-
1_4\lib\commons-discovery-0.2.jar;E:\Softies\axis-bin-1_4\axis-1_4\lib\jaxrpc.ja
r;E:\Softies\axis-bin-1_4\axis-1_4\lib\log4j-1.2.8.jar;E:\Softies\axis-bin-1_4\a
xis-1_4\lib\saaj.jar;E:\Softies\axis-bin-1_4\axis-1_4\lib\wsdl4j-1.5.1.jar
Regards
Ravi
At Server Side,i deply the wsdd file but at client side CalcClient is not be compiled,please give me suggesstions
ReplyDeletethat's wonderful article..i completed it with little difficulties as i was having my tomcat port as 8088 ....
ReplyDeletethanks a lot ! :)
Thank you Kamal! This tutorial helped me a lot to understand and solve my problem.
ReplyDeleteJust want to share my experience with executing WSDL2Java of Axis 1.4.
What is on my p c:
-------------------
1) JAVA_HOME variable value is set to jdk 1.5.
2) jdk 1.5 is in c:\pkg\java\jdk1.5\bin.
3) jdk 1.6 is in c:\program files\java\jdk1.6\bin.
4) Using JBoss Developer Studio, which is using jre 1.5.
Axis 1.4 configuration:
First follow the steps from above to download and to set CLASSPATH. Close the command window if it is open during setting the CLASSPATH.
Running WSDL2Java from Command prompt window:
c:\> Program Files\Java\jdk1.6.0_29\bin\java org.apache.axis.wsdl.WSDL2Java -o c:\temp\TestWebServiceClient -p Test.searchwebservices -s c:\temp\TestWebServiceClient\SearchWebServices-WSDL.WSDL
Guess what? I am new to Java.
--mkr
This is what I was looking for. This is really very very helpful tutorial for beginner like me. Thanks a lot Kamal for providing such easy to understand tutorial. Thanks again
ReplyDeletethanks boss! this will be very useful for beginners.
ReplyDeleteExcellent the comments helped me to solve my problem.
ReplyDeleteThanks to all.
Thanks for the simple explanation. Time Saver.
ReplyDeletegood, thank very much!!
ReplyDeleteI ran this command below, but i am getting following exception:
ReplyDelete>java org.apache.axis.client.AdminClient org\kamal\wssample\ws\generated\deploy.wsdd
{http://xml.apache.org/axis/}HttpErrorCode:404
Hi,
ReplyDeleteGood information on Axis setup. But do you know how to deploy my web service using to call a servlet which executes Adminclient for deploying? I was able to it post my application deployment but not during it. I am not entirely sure if my Axis servlet was still getting loaded up.
Hi Kamal !
ReplyDeleteThanks so much for your useful tutorial.
But I want to run my Web Service client on another computer.So what should i do for that !?
Thanks you !
Hi,
ReplyDeleteDo you have any idea what this error is all about?
Error: Could not find or load main class org.apache.axis.client.AdminClient
I tried to deploy a wsdd file and it results to this.
Thank you for sooner reply. :D
HINTS:
ReplyDeletestep 5: change lines of code and re-compile
otherwise it doesnt work. many users will have tomcat running on different port than 8080. change that with -p flag
thank you
where do you mention the usage of the deployed web service via stub in the client.
ReplyDeleteI am not sure if that was missed out