Though Seam 1.3 is currently only available from CVS, it shows a nice way to 
use web services with JBoss. This is based on standard Java annotations and 
JBossWS 1.2.1 GA, as packaged with JBoss AS 4.2.0 GA. Seam 1.3 adds (or, work 
in progress: hopefully will add) support for conversations working across 
multiple web service requests. Nice!

Though I have not used the Seam specific things, here's a start for a 
mini-HOWTO, of course calling for comments. And welcoming Seam specific 
enhancements!

If you need conversations you'll first need a Seam 3.1 snapshot from CVS  or 
get a nightly. This only runs on JBoss 4.2.0 CR1 or later (no need for any JEMS 
installer, just unpack the download). Again: I don't know the development 
status; when not using Seam conversations then the code below can also be run 
in JBoss without Seam at all -- but that's not what this forum is about...

The new SeamBay example shows how to define the web services. Here, 
AuctionService  uses @WebService and @WebMethod annotations (and implements 
AuctionServiceRemote to comply with the @Stateless annotation). No further 
configuration in, for example, web.xml, but an additional configuration file 
META-INF/standard-jaxws-endpoint-config.xml for JBossWS. The name of this file 
could be changed using a JBoss proprietary annotation, @EndpointConfig.

After deployment, one would see the web services listed at 
http://localhost:8080/jbossws/. For JBoss 4.2.0 CR1 this gives URLs such as 
/seam-bay-seam-bay/AuctionService; in 4.2.0 CR2 and GA one gets the newer 
jbossws-1.2.1.GA, which creates URLs like 
/AuctionServiceService/AuctionService. Heiko Braun explained this in another 
forum post. 

Heiko also explained why this new mechanism might cause "Multiple context root 
not supported" errors, and that one can change the context path using another 
JBoss proprietary annotation, @WebContext from jbossws-core.jar. This error may 
also be caused by some left-overs after refactoring. I changed the name of my 
service using Eclipse, which left the old compiled classes in various exploded 
EAR folders. As those were then still loaded by JBoss this resulted in multiple 
services within the same application, and thus resulting in the "not supported" 
error.

Even when not running into errors it might be a good idea to somehow get a 
defined context path for the web service, as you do not want to have the 
clients know about a new URL when you upgrade the JBoss application server... 
Or maybe one should forget about the automatic deployment and simply go back to 
adding the web services to web.xml for better control. Any thoughts on this?

So, the following (which is not Seam specific) works just fine in AS 4.2.0 GA, 
if you include some  META-INF/standard-jaxws-endpoint-config.xml in your 
project:

package my.package;
  | import javax.jws.WebMethod;
  | import javax.jws.WebService;
  | 
  | // The Service Endpoint Interface
  | @WebService
  | public interface DeepThoughtSEI {
  | 
  |   @WebMethod
  |   public String getAnswer();
  | 
  | }

and

package my.package;
  | import javax.ejb.Stateless;
  | import javax.jws.WebMethod;
  | import javax.jws.WebService;
  | import org.jboss.ws.annotation.WebContext;
  | 
  | @Stateless
  | @WebContext(contextRoot = "/guide/to/the/galaxy")
  | @WebService(endpointInterface = "my.package.DeepThoughtSEI")
  | public class DeepThought implements DeepThoughtSEI {
  | 
  |   public String getAnswer() {
  |     return "42";
  |   }
  |      
  |   public String getUltimateQuestionToLifeTheUniverseAndEverything() {
  |     return "sorry, not exposed in endpointInterface";
  |   }
  | 
  | }

This serves the WSDL at 
http://universe.tld/guide/to/the/galaxy/DeepThought?wsdl 

Note that when not specifying a value for endpointInterface then ALL methods in 
the DeepThought implementation would be exposed, unless at least one method is 
explicitly annotated in that class -- even though the interface explicitly only 
declares a single method to be exposed. In other words: the @WebMethod 
annotations in the interface are only honored when endpointInterface is used. 
But this is all not Seam specific.

More documentation at the JBoss JAX-WS User Guide.
CVS at :pserver:[EMAIL PROTECTED]:/cvsroot/jboss/jboss-seam

Enjoy,
Arjan.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047886#4047886

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047886
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to