views:

159

answers:

2

Background

I am attempting to make a webservice using SOAP and JBOSS. I know that to make a webservice that you do something like this:

import javax.jws.WebService;

@WebService
public class HelloImpl {

  /**
   * @param name
   * @return Say hello to the person.
   */
   public String sayHello(String name) {
     return "Hello, " + name + "!";
   }
}

I understand in general how java annotations work:

@nnotations are defined by the Java language. An Annotation is a class. When you mark something with an annotation, the compiler and runtime arrange for an object of that class to be visible at runtime via java reflection.

Thanks to bmargulies from this thread.

I am not certain what jboss does with the annotaions.

Question 1: What I think is that jboss either generates xml OR wsdl based on the annotations. Is this correct? Note: I am refering to tags like @Webservice, @WebContent, @SecurityDomain, @Stateless

Question 2: If jboss does generate xml OR wsdl do I need the annotations? Am I allowed to just create that file myself?

Similar Pages:

+1  A: 

You should more see the annotations as a replacement/alternative to XML configuration files. When JBoss starts up it just scans the entire classpath for classes with the particular annotations and then loads/instantiates/maps them in the memory. If no annotations were used here, JBoss would just parse and read the XML configuration file for hints where the particular classes are located and/or how to handle them and then loads/instantiates/maps them each in the memory roughly the same way.

You're free to define XML config files yourself. You can even use it simultaneously with annotations, but keep in mind that XML config files (usually) outweights/overrides the same configuration which is definied in flavor of annotations -if any. This because XML config files are externally controllable without the need to rewrite/rebuild/redeploy all the Java code again and again. JBoss does not generate XML files based on the annotated classes.

BalusC
+1  A: 
  1. JBoss's web services stack is just an implementation of JAX-WS (JSR 224). JBoss should generate the WSDL for you, usually accessible at the webservice's url with ?wsdl appended to the end.

  2. The WSDL isn't the only thing those annotations do. They also tell JBoss that your class implements one or more web services.

The JavaEE tutorial has a section on Web Services with JAX-WS that explains how they work in more detail.

R. Bemrose