This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
After searching all over the place for a solution, I could not find it ... until I started reading the Java EE 5 tutorial. Its on Page 488 of the Java EE 5 tutorial PDF. After some guessing, the following works.
This is using NetBeans IDE 6.8 (needless to say, I don't know how to do the same thing in Eclipse)
Project structure looks like this:
HelloWs (Create a project of type Java Web->Web Application)-->Web Services-->HelloWebService
Create the web service project Create a web service called HelloWebService in the project, and make a note of the service name you provide.
HelloWsClient (Project type is Java EE->Enterprise Application Client)
// note that HelloWs is the project and GreeterWs is the exposed service name
GreeterWs service; // will be injected. note the data type of the variable. its the service name provided in the @WebService annotation
Make sure that you can see the wsdl. Right-click the client project and select Run File, and it should work.
Hope this is helpful to someone!
Now a question if you are still reading this. I am assuming that we just created a "managed" JAX-WS client. This works because I have Glassfishv3 on my local machine. What if the web service were on a remote server and the local machine running the client did not have Glassfish installed? So there is nothing on the client side to "manage" it. Would the client still work?
To launch a managed client independent of any IDE, you use the appclient command in the GlassFish distribution: http://docs.sun.com/app/docs/doc/820-7701/appclient-1m?a=view You only need an Application Client Container, in order for this to work, not the entire GlassFish container. I haven't used a standalone Application Client Container yet, though.
Joined: Feb 19, 2010
Thank you, Ivan, for the pointer to the appclient man page!
I noticed that NetBeans generates two jars for project HelloWsConsumerClient:
I am able to run the client in two ways now from the <netbeans project directory>\dist directory:
1. <glassfishv3 install dir>\glassfish\bin\appclient -jar .\HelloWsConsumerClient.jar
2. <glassfishv3 install dir>\glassfish\bin\appclient -client .\HelloWsConsumerClientClient.jar