Java Reference
In-Depth Information
@Stateless
@Local
public class CatalogEJB {
@WebMethod
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,
use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.BARE)
public @WebResult(name="book",
targetNamespace="http://ns.soacookbook.com/catalog") Book
getBook(
@WebParam(name="isbn",
targetNamespace="http://ns.soacookbook.com/catalog") String
isbn) {
LOG.info("Executing. ISBN=" + isbn);
Book book = new Book();
//you would go to a database here.
if ("12345".equals(isbn)) {
LOG.info("Search by ISBN: " + isbn);
book.setTitle("King Lear");
Author shakespeare = new Author();
shakespeare.setFirstName("William");
shakespeare.setLastName("Shakespeare");
book.setAuthor(shakespeare);
book.setCategory(Category.LITERATURE);
book.setIsbn("12345");
} else {
LOG.info("Search by ISBN: " + isbn + ". NO RESULTS.");
}
LOG.info("Returning book: " + book.getTitle());
return book;
}
//...
}
The web service operates using the http://ns.soacookbook.com/ws/catalog namespace,
and the schema-based artifacts are defined in the http://ns.soacookbook.com/catalog
namespace. Your build process uses XJC to generate Java objects based on the schemas before
compiling the service. The robust business logic in this example just indicates that you'll get
a book result back if you pass in “12345” as the ISBN, and an empty book otherwise.
Search WWH ::




Custom Search