The Source for Java Technology Collaboration
User: Password:



Jitendra Kotamraju

Jitendra Kotamraju's Blog

Google's AdSense and JAX-WS

Posted by jitu on April 12, 2007 at 11:19 AM | Comments (2)

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 com.google.api.adsense.v2 -d gen https://www.google.com/api/adsense/v2/AccountService?wsdl
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();
((WSBindingProvider)accountService).setOutboundHeaders(
    fact.createDeveloperEmail(developerEmail),
    fact.createDeveloperPassword(developerPassword),
    fact.createClientId("ignored"));
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

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Excellent! Thanks so much for sharing this!

    Posted by: missdanni on November 04, 2007 at 01:50 PM

  • Adsense API does provide clean and simple interface to help developers produce required interactive pages for users to manage and create Adsense accounts.

    http://adsense-primer.blogspot.com

    Posted by: guyritchie2006 on November 21, 2007 at 08:13 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds