I am very new to the webservices technology so please bear with me and help me out if you can.
There is a webservices (not developed by me) which is deployed on websphere server and I have been given a wsdl file. Now I want to call this webservice from my jsp file which is deployed on a differen server. Can this be done. I have heard there is a tool called wsdl2java which converts the wsdl file to java files and we just have to import those java files and call the functions as we normally do. Is that all that is required from me? Do I need to install axis or anyother such thing to be able to use wsdl2java? Morover from where do I download this tool?
Would appreciate if someone replies or point me over to some links..
Originally posted by Alex Luc:
Do I need to install axis or anyother such thing to be able to use wsdl2java?
If you choose to use Axis as your SOAP stack then installing Axis is the easiest way to go. However you only need to deploy the generated client stubs and any axis jars that those stubs reference to the actual client. Many of the more recent platform IDEs will give you similar functionality without having to introduce Axis.
You haven't mentioned whether you intend to use Axis 1.x or Axis 2 (which requires Java 1.5). For Axis 1.x Creating Web Services with Apache Axis will give you an idea what you need to do to create the client stubs.
Moreover from where do I download this tool?
For Axis it is part of the normal distribution. It's the org.apache.axis.wsdl.WSDL2Java class (Axis 2 has a wsdl2java.bat/sh script in the bin directory).
Tried to run wsdl2java but got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis/wsdl/WSDL2Java
I ran this from the directory in which axis.jar is located... Should the server be started when I run this?
[ August 06, 2007: Message edited by: ubz tayb ]
Also..It has created a lot of files.
Two interfaces WSName, WSNameService and 2 classes WSNameSeviceLocator WSNameSoapBindingStub. Now which files do I include and what functions do I call I from my jsp?
[ August 16, 2007: Message edited by: Alex Luc ]
Originally posted by Alex Luc:
One thing I didnt understood was if .(dot..current directory) is in my classpath and I execute WSDL2Java from the folder in which the jar files are located, then I SHOULD be able to run
Incorrect. Including the current directory in your class path allows you to "pick up" *.class files in the current directory, not *.jar files (they have to be mentioned explicitly). Also with Axis there is the matter of the AXIS_HOME and AXISCLASSPATH environment variables that have to be set properly.
Now which files do I include and what functions do I call I from my jsp?
Look again at 3. WSDL2Java: Generate the Server-side Wrapper Code and Stubs For Easy Client Access. According to the article nothing is unexpected.
Then look at 6. Client: Write a Client That Uses the Generated Stubs to Easily Access the Web Service. You need something along the lines of
Try the code first as a simple command line program. Once you get that working you will have the code you need in the JSP.