|
-
Aug 14th, 2006, 04:01 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] How do you make java web service?
Do you guys have a link or an simple sample of a java web service(Like a web service that returns a string of "Hello World")? I've only worked with .Net stuff, and I'm not familiar with Java web service.(I only know basics of java).
-
Aug 14th, 2006, 05:10 PM
#2
Re: How do you make java web service?
Look at JAX-WS or Axis. One is a specification for a method of creating web services, the other a web service container. In particular, you might want to look at Axis2.
http://ws.apache.org/
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 14th, 2006, 05:27 PM
#3
Thread Starter
Frenzied Member
Re: How do you make java web service?
I also want to mention that it has to be done in windows(or DOS). I'm not familiar with unix or linux stuff. Are the ones mentioned above do-able in windows?
-
Aug 14th, 2006, 05:36 PM
#4
Re: How do you make java web service?
Java is platform-independent.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 14th, 2006, 06:16 PM
#5
Thread Starter
Frenzied Member
Re: How do you make java web service?
Ok, i've seen this Apache SOAP version 2.2, and it tells me that I would have to create an "Apache SOAP deployment descriptor". Does the Apache SOAP do this for me, or do I have to type it up myself? And where do I put all these files at? I have IIS. Do I put it there like any other web page?
-
Aug 14th, 2006, 06:19 PM
#6
Re: How do you make java web service?
You have to install a servlet container, like Apache Tomcat. IIS can't serve Java stuff. The deployment descriptor, it can create for you, but I forgot how.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 15th, 2006, 11:01 AM
#7
Thread Starter
Frenzied Member
Re: How do you make java web service?
If I was to install Apache Tomcat, will that mess with the IIS configuration?
-
Aug 15th, 2006, 11:13 AM
#8
Thread Starter
Frenzied Member
Re: How do you make java web service?
I'm really confused now...I just downloaded two zips from http://apache.forbigweb.com/ws/soap/version-2.3.1/ One is the bin and the other is the src. I can't find any executables to install the Apache Soap. Am I suppose to execute through java? If so, which one? there are so many files. Do you know any web sites that show a more thorough way of creating web service. More step by step.
-
Aug 15th, 2006, 11:17 AM
#9
Re: How do you make java web service?
Search Google. I don't know of any sites, and the installation process is not trivial. The Apache site has installation instructions for Axis, but that requires that you first install Tomcat. Tomcat, in turn, ought to have a proper installer that installs it as a Windows service.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 15th, 2006, 02:48 PM
#10
Thread Starter
Frenzied Member
Re: How do you make java web service?
Ok, I got the Tomcat working. But it tells me now to set my CLASSPATH. How do I set my CLASSPATH?
Here is a quote from a tutorial:
For the Apache SOAP client to work, Xerces, Apache SOAP, JavaMail and the Java Activation Framework should be in the CLASSPATH. It so happens that Tomcat includes usable versions of Xerces, JavaMail and Java Activation Framework. I set my CLASSPATH to the following.
.;j:\jakarta-tomcat-4.0.1\common\lib\xerces.jar;j:\soap-2_2\lib\soap.jar;j:\soap-2_2; j:\jakarta-tomcat-4.0.1\common\lib\mail.jar;j:\jakarta-tomcat-4.0.1\common\lib\activation.jar
How do i set the CLASSPATH? is it SET CLASSPATH = (above)
or SET PATH = (above)
-
Aug 15th, 2006, 03:04 PM
#11
Re: How do you make java web service?
Out of interest, why Tomcat 4.x? Tomcat 5.5.x is more up-to-date, and the website says:
We encourage all users to upgrade to Apache Tomcat 5.x whenever possible.
I'm guessing it's because 4.0.1 is used by the author of the installation document. But that document is over two years old and says 4.x or later. 5.5 is much better. Don't hesitate to install it.
As for Apache SOAP, don't use it. It has been superseded by Apache Axis, which in turn has been superseded by Axis2.
Tomcat installation: http://tomcat.apache.org/tomcat-5.5-doc/setup.html
Axis2 installation: http://ws.apache.org/axis2/1_0/insta...l#_Toc96698086
Just follow those instructions. You will probably have to restart Tomcat to make it pick up the WAR. Alternatively, you can use Tomcat's management servlet to install the WAR.
After that, grab an Axis2 sample application and see if you can get that running. Finally, follow the Axis2 user guide to learn how to make web services.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 15th, 2006, 04:10 PM
#12
Thread Starter
Frenzied Member
Re: How do you make java web service?
Thanks for help. I'll check those out.
-
Aug 15th, 2006, 06:12 PM
#13
Thread Starter
Frenzied Member
Re: How do you make java web service?
Thanks again, I finally got the Tomcat and Axis2 installed. Now you said something about an example of axis2 application. Is this sample like a web service or web application? I'm looking more towards web service where I just create a method.
-
Aug 15th, 2006, 06:22 PM
#14
Re: How do you make java web service?
No idea. Some distributions of Axis2 (but not the WAR one that you downloaded, I think) contain sample applications. You'd have to look at them. Also, the Axis2 site contains a user guide which gives, I think, quite a good introduction.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 16th, 2006, 12:12 PM
#15
Thread Starter
Frenzied Member
Re: How do you make java web service?
-
Aug 16th, 2006, 02:57 PM
#16
Thread Starter
Frenzied Member
Re: How do you make java web service?
Still having trouble making the web service. The first step says that I create the class implementation, so I just use the sample they gave. Then it says to create a deployment descriptor, so I also am using the sample the gave. Then it tells me to create a .jar file, but for me to create that, I need to make a .class out of the .java which I am unable to do because it keeps telling me that the imported class can't be found; specifically the following:
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
Here is the whole code:
Code:
package userguide.example1;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import javax.xml.stream.XMLStreamException;
/**
* Created by IntelliJ IDEA.
* User: Jaliya
* Date: Jun 2, 2005
* Time: 2:17:58 PM
*/
public class MyService {
public OMElement echo(OMElement element) throws XMLStreamException {
//Praparing the OMElement so that it can be attached to another OM Tree.
//First the OMElement should be completely build in case it is not fully built and still
//some of the xml is in the stream.
element.build();
//Secondly the OMElement should be detached from the current OMTree so that it can be attached
//some other OM Tree. Once detached the OmTree will remove its connections to this OMElement.
element.detach();
return element;
}
public void ping(OMElement element) throws XMLStreamException {
//Do some processing
}
public void pingF(OMElement element) throws AxisFault{
throw new AxisFault("Fault being thrown");
}
}
I'm trying to follow the instruction from this url:
http://ws.apache.org/axis2/1_0/userg...s_Primary_APIs
I also still confused to which folder I'm supposed to copy those files mentioned above.
The current folder path of my axis2 is:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis2.war
This is getting so confusing. I'd really appreciate anymore help on this.
-
Aug 16th, 2006, 03:15 PM
#17
Re: How do you make java web service?
When compiling the .java file, you need to add the various libraries of Axis to the classpath. This is similar to adding references to assemblies to your project in .Net. How exactly you do that depends on your development environment, but here's how you might do it on the command line:
Code:
javac -cp %CLASSPATH%;C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis2.war;. userguide\example\MyService.java
Guessing at classpathes can be complicated. An IDE like NetBeans or Eclipse can help you there.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 16th, 2006, 05:05 PM
#18
Thread Starter
Frenzied Member
Re: How do you make java web service?
I think I know where all the jar files are for those imports. Question is...how do I set the classpath so that I don't have to type:
javac -cp "c:\a.jar;c:\b.jar;c:\c.jar;c:\d.jar(and so on)" MyService.java
Also, i found the sample .aar so I'm working with that for now. I copied it to:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis2.war\WEB-INF\services
And when i go to:
http://localhost:8080/axis2/services/listServices
I can see the "MyService", and when I try to go to:
http://localhost:8080/axis2/services/MyService?wsdl
I get the message:
Either user has not dropped the wsdl into META-INF or operations use message receivers other than RPC.
I'm guessing this has something to do with the fact that I have not placed the deployment descriptor in the correct folder. Where do I put it if my current folder path is:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis2.war
the folders inside axis2.war are "axis2-web", "META-INF", and "WEB-INF". I've tried putting the EXACT services.xml that was in the sample in META-INF and WEB-INF, but to no avail.
-
Aug 16th, 2006, 05:12 PM
#19
Re: How do you make java web service?
 Originally Posted by benmartin101
I think I know where all the jar files are for those imports. Question is...how do I set the classpath so that I don't have to type:
javac -cp "c:\a.jar;c:\b.jar;c:\c.jar;c:\d.jar(and so on)" MyService.java
I use Ant to compile my projects.
Can't help you with the other problem. I've never used Axis2, actually, I'm still stuck with Axis1.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 16th, 2006, 05:17 PM
#20
Thread Starter
Frenzied Member
Re: How do you make java web service?
Ok, I just realized something. After installing Tomcat, all I did next to "install" apache was copy the axis2.war folder in the "webapps" folder of Tomcat. But in the same website I downloaded axis2.war, there is a axis2 "bin" file that has "bin", "lib"(this seem to have the .jar files), "module", and "sample" folder. Am I suppose to copy this too? If so, where? The instruction never told me to install this, just the war file.
-
Aug 16th, 2006, 05:19 PM
#21
Re: How do you make java web service?
No, actually it contains pretty much the same stuff, except that the WAR doesn't have the samples. But you can still grab the bin file, if only for the samples.
(Look inside the WAR file, you'll find the JARs there, too.)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 17th, 2006, 01:23 PM
#22
Thread Starter
Frenzied Member
Re: How do you make java web service?
Ok, i'm getting real close now. I am now able to create the jar file, which I rename to a .aar file. I then put it in the \webapps\axis2.war\WEB-INF\services folder and when I look at the list of services currently deployed, the service I deployed is there. Now here is the problem I ran into, when I try to connect using "?wsdl":
http://localhost:8080/axis2/services...teService?wsdl
I get an error message saying:
<description>Unable to generate WSDL for this service</description>
<reason>Either user has not dropped the wsdl into META-INF or operations use message receivers other than RPC.</reason>
I'm not sure exactly how to handle this. Do I make a file for the wsdl? I checked the sample .aar(which is the version.aar - its function is to get the version of Axis2). I renamed it to a .jar file and extracted it(this is how I figured out some of the problems I had) and saw a META-INF folder containing "services.xml" and a "sample" folder, which contains an "axisversion" folder"(this folder contained another META-INF folder, containing identical "services.xml", and the "version.class" file). That is all the files that are inside the jar file (pretty much what I had in my StockQuoteService.jar). But when I go to:
http://localhost:8080/axis2/services/version?wsdl
the wsdl definition was returned ( I assumed this is the correct response).
So, I'm assuming that for StockQuoteService to work properly, it shouldn't return an error message when I go to the ?WSDL. Any idea?
-
Aug 17th, 2006, 01:39 PM
#23
Re: How do you make java web service?
How about the services.xml of the example and of your code? Are they identical (except for obvious differences)? Is the coding technique the same in both? What I mean is, does the sample use OMElement as function parameters, or other types? How about your code?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 17th, 2006, 02:41 PM
#24
Thread Starter
Frenzied Member
Re: How do you make java web service?
Yeah, it uses OMElement. I pretty much used the same coding technique with the services.xml. Not sure about the version.class because I can't see the .java file. But yeah, it is using OMElement. But here's something weird, don't know if it makes a difference. In the example, it originally imports:
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMFactory;
import org.apache.axis2.om.OMNamespace;
But it didn't compile when I used this command line:
Code:
javac -cp "C:\Program Files\Java\jdk1.5.0_05\bin\axis2-codegen-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axis2-adb-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axis2-java2wsdl-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axis2-jibx-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axis2-kernel-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axis2-soapmonitor-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axis2-xmlbeans-1.0.jar" StockQuoteService.java
But when i change the import to(basically changed axis2 to axiom):
import org.apache.AXIOM.om.OMAbstractFactory;
import org.apache.AXIOM.om.OMElement;
import org.apache.AXIOM.om.OMFactory;
import org.apache.AXIOM.om.OMNamespace;
and used command line:
Code:
javac -cp "C:\Program Files\Java\jdk1.5.0_05\bin\axiom-api-1.0.jar;C:\Program Files\Java\jdk1.5.0_05\bin\axiom-impl-1.0.jar" StockQuoteService
then it works. Did they just write it wrong? Or am I using the wrong classes?
-
Aug 17th, 2006, 02:45 PM
#25
Re: How do you make java web service?
I'm sorry, I'm out of my depth here.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Aug 17th, 2006, 03:45 PM
#26
Thread Starter
Frenzied Member
Re: How do you make java web service?
Well, thanks for the help anyways.
-
Aug 17th, 2006, 04:43 PM
#27
Thread Starter
Frenzied Member
Re: How do you make java web service?
I finally figured out why the ?WSDL wasn't working. I had to messageReceiver to:
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|