users@glassfish.java.net

JAX-WS Applications Doubt

From: <glassfish_at_javadesktop.org>
Date: Tue, 29 Jun 2010 07:19:29 PDT

Hi,

I am lost in JAX-WS chaos!

Essentially, I've been trying to build a simple web service application (e.g: the AddNumbers web service that comes in the Samples from Metro).

But after reading several web pages, and playing around with my eclipse, I've come to harvest many many doubts.

I will post them here, in hopes that someone might shed some light to many of my issues.

(1) Java has many APIs related to the development of web services (e.g: jax-WS, Jax-B, and so on). But developing these applications, at least for me, seems to result in utter chaos for many reasons:

1.1 Where are the Jars comprising these API's supposed to be located?
Related facts: I've seen them in a hundred different places. I have Java JDK 1.6 installed in this computer, and it comes with a JAX-WS.jar but brings no JAX-B.
I've downloaded the current Metro Release, which seems to bring all the essential Jars, namely the webservices-api.jar that seems to be the fusion of JAX-B with JAX-WS.
I've even installed the Metro web services stack in my GlassFish 3 using the update tool, and many of the .jars that came with my Metro Download don't seem to exist anywhere among my glassfish libraries.
So it seems, that neither is there any standard name for these libraries, nor any default release providing them.

This confuses me greatly because now I don't know what my classpath should be like?

(2) Should my classpath be pointing to the GlassFish libraries?
This would make sense since glassfish will be the container of my Web APP.
On the other hand, There is no way I can build a Java Application in eclipse without including having my JDK libaries in the classpath. So I have redundancy in .jars and ocasionally even mixes of different versions of the same libraries which result in strange compilation errors.

(3) When I use the APT ant task, my ant is using the APT implementation of my JDK. Again, should i be using the TOOLS.jar that comes with glassfish, or the one that comes with Metro or the One in my JDK?

(4) When I tried to use the WSGEN ant task supported in the Metro Tools.jar, I got compilation erros, because apparently my JAX-WS implemenation of my JDK is too outdated.
 Then how can I compile this application using the Metro tools, if they are too recent when compared to my JDK?

(5) I've seen a hundred pages trying to explain how to deploy you WAR files in glassfish.
But what does GlassFIsh really want you to put in the WAR file? Does it want you to produce the WSDL and APT stubs before deployment? Or does it do it on its own?

So far, I saw no one clearly answering which files I should place in my WAR file for it to properly work.
I've seen people saying that if you are Going Java->WSDL:
you don't need to do almost anything. Once you deploy the WAR file containg (WEB.XML and you user classes), Glassfish will automatically use Wsgen and APT to produce both your WSDL and the JAX-B incoming message and response of your service operations.

5.1 I've tried making WARs containing both APT classes and without them, in both cases I got correct deployments (no errors reported); but when I tried to access the Servlet link there was a "resource not found" reply from the server.

Let me give you an example.
It does not use code developed by me.
1st: I donwloaded the latest version of metro.
2nd: Opened a windows cmd.exe in METRO_HOME/samples/fromjava_no_wsgen
3rd: In the promt I wrote > ant build-served-java (this just compiles your user sources, does not generate any stubs. its just a javac over your srcDir)
4th: ant create-war
5th: asadmin deploy build/war/jaxws-fromjava_no_wsgen.war
6th: Success

So far no problems to report.
But then I've been told that If you web service is correctly deployed, then if you go to the web.xml servlet link you should retrieve the web service wsdl.
Well, when I go to "http://localhost:8080/addnumbers"
I get a resource not available response from the server.
I am assuming this would be the correct link since the WEB.xml configures the sevlet as follows:
 <servlet-mapping>
        <servlet-name>fromjava_no_wsgen</servlet-name>
        <url-pattern>/addnumbers</url-pattern>
</servlet-mapping>
Morever, if I go into the administration console, GlassFish seems to think that the service should be acessfile in the url /war-file-name, which in this case woul be:
http://localhost:8080/jaxws-fromjava_no_wsgen.
In both cases I get the 404 response.


Something else that confuses me is the web.xml file and sun-jaxws.xml. Are these two files complementary? The web.xml defines a servlet name for this Java Web Application, but chooses as an implementing clas some generic WebService Servlet class:
<servlet>
        <description>JAX-WS endpoint - fromjava_no_wsgen</description>
        <display-name>fromjava_no_wsgen</display-name>
        <servlet-name>fromjava_no_wsgen</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

On the other hand, the sun-jaxws.xml in fact names the Application class with the @WebService annotation, but it makes no direct refence to the "fromjava_no_wsgen" servlet defined in the web.xml document.

<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
    <endpoint
        name='fromjava'
        implementation='fromjava_no_wsgen.server.AddNumbersImpl'
        url-pattern='/addnumbers'/>
</endpoints>

So if they are complementatry, how does GlassFish know that when a request targets the com.sun.xml.ws.transport.http.servlet.WSServlet, this request should be transferred to the implementing class "fromjava_no_wsgen.server.AddNumbersImpl".


Finally, can anyone actually summarize the correct Web Service development procedure?

Like:
1: Make your class that uses @webService and @WebMethod
2: Compile your application using the APT tool (the one in the GlassFish web serrver - or somewhere else - i am not sure which should be used)
3: Generate your web service wsdl
4: Use Ant to make a WAR File containing all the previous stuff + web.xml and sun-jaxws.xml
5. AsAdmin deploy the war file
6: access sevletUrlPattern to cheack is your WSDL is accessible, which should imply everything worked out fine.

I don't know if what I said is correct.
I know that I am having difficulty making the deployed web services work properly.


My best regards,
Thanks In advance,
Nuno.
[Message sent by forum member 'sono99']

http://forums.java.net/jive/thread.jspa?messageID=476309