Skip to main content

Google's AdSense and JAX-WS

Posted by jitu on April 12, 2007 at 11:19 AM PDT

I came across Google's AdSense API Developer's Guide. Disappointed to see that there is no JAX-WS sample client code. So I looked at the Axis client, thought JAX-WS client code would look the same. Indeed, it was the case.

First need to create a proxy code. Used JAX-WS's wsimport to create proxy code. The generated code is completely portable and much smaller. Here is the command:

wsimport -p -d gen

This WSDL defines additional headers in soap:binding section. soap:binding changing the porttype by adding additional headers is not a good idea. JAX-WS doesn't
capture these in the SEI. The portable way to add these headers to the messages is using SOAP handlers. Using SOAP handlers is a bit complex, but we can add these headers easily using RI's extension. This is similar to what Axis is doing in the axis sample code. But in our code, we could use JAXB !.

ObjectFactory fact = new ObjectFactory();

The other difference is some types are mapped to List. One can get arrays also
by passing customization files to wsimport.

Here is the complete sample code using JAX-WS