Sunday, June 13, 2010

WebServices with CXF - Integrating with CXF I

As I said before on Service Interface & Implementation, somehow we'll have to retake that code to implement CXF, and that's what we're going to do.
I want to expose as WebService my LibraryService and as WebMethods these methods:

  • public List getAllAuthors()
  • public List getAllBooks()
  • public List getAllEditors()
  • public List getAllOnlyEditors()
  • public BookDTO getBook(Integer bookId)
Ok, everything looks nice, but what happens if my client is asking for a "subService" (WebMethod) which returns AllAuthors, but he/she doesn't expect a WebMethod called getAuthors, retrieveAuthors or returnAuthors.
What can we do??? -We're done with our coding and that method (getAllAuthors) is being used in many places in our App.
Are you going to rename your code just because your client doesn't like your naming convention???. Later you'll see my answer.

Let's modify my code, first, Interface then Implementation;
By adding Java WebServices API Annotations And don't forget for every method we must declare it like a WebMethod In this case I'm declaring a couple of additional attributes, which basically let me give another name to WebMethod, a different name to my original Java Method - this will be the name available on my WebService/WebMethod (this is the second option for my client)

And finally, what can I do if have logic on this interface that I don't want to make it public (available as WebMethod)???
This is the answer: "Just exclude it"

No comments:

Post a Comment