Annotating the SEI
About this task
The SEI requires that you add the @WebService annotation. Since the SEI is the contract that defines the service, you should specify as much detail as you can about the service in the @WebService annotation's properties.
The below shows the interface defined in above with the @WebService annotation.
Interface with the @WebService Annotation
package com.mycompany.demo;
import javax.jws.*;
@WebService(name="quoteUpdater",
targetNamespace="http://cxf.apache.org",
wsdlLocation="http://somewhere.com/quoteExampleService?wsdl")
public interface QuoteReporter {
public Quote getQuote(@WebParam(name="ticker") String ticker);
}
The @WebService annotation above does the following:
Procedure
- Specifies that the value of the name attribute of the wsdl:portType element defining the service interface is quoteUpdater .
- Specifies that the target namespace of the service is http://cxf.apache.org.
- Specifies that the service will use the pre-defined WSDL contract published at http://somewhere.com/quoteExampleService?wsdl.
Results
The @WebParam annotation is necessary as java interfaces do not store the Parameter name in the .class file. So if you leave out the annotation your parameter will be named arg0.