Skip navigation

A little over a week ago, Richard Monson-Haefel posted a blog entry trashing the new Java Web Services standard, JAX-WS. He even went so far as to say:

"You guys ought to be ashamed of yourselves. You could have taken this opportunity to re-engineer J2EE web services into something really simple, but you decided to put lipstick on the Pig instead."

Not only was this an unfair evaluation, but the only proof he offered was a rhetorical challenge, to try and implement a real world web service such as Amazon or eBay. The reward, he would eat his words.

So, in order to redeem JAX-WS, I decided to show just how easy it is by taking his challenge. I posted directions for a client that communicates with eBay in his blog comments. To be honest, I never expected to hear anything; however, to my surprise, he literally ate his words. I have to hand it to him for that. Although, he didn't have to go that far (I'm not that mean), a simple correction would have been nice.

Unfortunately, even after eating his words, he still stands by them. Although, this time he says he just means the server side. So here it is folks, the server (notice the steps are almost the same as the client):

  1. Download and install the JAX-WS RI into whatever container you use
  2. Use wsimport, and import the EBay WSDL.
  3. Fix a bug in the RI by correcting the generated endpoint interface to use the following annotation and parameter:

      @WebParam(name = "RequesterCredentials", 

                targetNamespace = "urn:ebay:apis:eBLBaseComponents", 

                partName = "RequesterCredentials", header = true)

      CustomSecurityHeaderType header

  4. Write this class:

    package server;

     

    import ebay.apis.eblbasecomponents.*;

    import javax.jws.*;

     

    @WebService(

       endpointInterface="ebay.apis.eblbasecomponents.EBayAPIInterface")

    public class MyEBay implements EBayAPIInterface

    {

        // Use your favorite IDE to implement all interface methods

        // (Omitted for clarity)

     

       public GetItemResponseType getItem(GetItemRequestType request,

                                          CustomSecurityHeaderType header)

       {

          GetItemResponseType response = new GetItemResponseType();

          ItemType item = new ItemType();

          item.setTitle("J2EE WEB SERVICES BOOK NEW RICHARD MONSON-HAEFEL");

          response.setItem(item);

          return response;

       }

    }

  5. build a war with the generated classes, the one developed above, and a web.xml, and sun-jaxws.xml. You can just copy and modify them from the samples directory.
  6. Deploy it and run the client

Filter Blog

By date:
By tag: