I am updating the “External Services” chapter in Core JSF. There is lots of new and interesting stuff: How to use JPA, stateless session beans, and WebBeans. I ditched the LDAP sections (for which I had received very few queries, even though the examples are notoriously hard to set up). I reimplemented the authentication example with a JDBC realm, which was no fun. Now I am at the web services section.
In the previous edition, I used the Amazon e-commerce service that lets you browse the Amazon catalog. It is pretty simple, really. Inject the service into a managed bean:
@WebServiceRef(wsdlLocation= "http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl") private AWSECommerceService service;
Then call the service API.
Generate the client-side artifacts:
wsimport -p com.corejsf.amazon http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl jar cvf aws.jar com/corejsf/amazon/*
Put the JAR file into
WEB-INF/lib. Deploy, and it just works.
Except that Amazon has repositioned the API as a “product advertising API”, and you now need to be an “Amazon associate” to use it, which makes it less suitable for a book example.
wsimport -p com.corejsf.noaa http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl parsing WSDL... [ERROR] rpc/encoded wsdls are not supported in JAXWS 2.0. line 405 of http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl wsimport -p com.corejsf.bing http://api.search.live.net/search.wsdl parsing WSDL... [ERROR] A class/interface with the same name "com.corejsf.bing.SearchRequest" is already in use. Use a class customization to resolve this conflict. line 1 of http://api.search.live.net/search.wsdl [ERROR] (Relevant to above error) another "SearchRequest" is generated from here. line 1 of http://api.search.live.net/search.wsdl (followed by seven more errors)
WT-*? Aren't these supposed to be interoperable?
Am I beating a dead dog here? This article describes research on finding web services. In 2008, they found a few thousand services, most of which didn't seem to work. Are WS-* services the new CORBA? I know there are lots of interesting RESTful services out there. The only drawback for me is (1) the data comes back as some ad-hoc XML, RSS, or JSON, and I have to deserialize it by hand and (2) there is no connection to JSF.
If you can point me to an interesting WS-* service that is free to use, likely to stay around for a few years, and has a WSDL that
wsimport can process, I would very much appreciate if you leave a comment. Or, talk me into dropping the web service section altogether.