Creating EJB Proxies to External WebServices Using the Dispatch API
By Mark Foster on Sep 12, 2008
Whilst JavaCAPS6, and specifically the HTTP Binding Component, have many useful features, there are currently limitations with it, notably calling JAX-RPC webservices using soap encoded arrays and calling webservices using SOAP1.2.
With JAX-WS you get access to the Dispatch API which makes it easy to call both of these use-cases from Java code.
Wrapping the Dispatch code inside an EJB, exposed as a doc/literal webservice, is a simple way to create a proxy to these external webservices, this EJB-WS can then be called from BPEL, for example, via the JavaEE SE making the overall process very efficient.
So, how do we do this........
1. Find an example RPC/encoded webservice - try this one which returns a quotation
2. Create a EJB project inside NetBeans
3. Create a WSDL to expose your EJB as a webservice
4. Do not create a WebService Client - this is an un-necessary step, we will do this dynamically in the code
5. Start coding, the code below can be used to call the above webservice and respond with the quotation string, pay special note to how the qualified names for the serviceName and portName are constructed and how they relate to the underlying WSDL.....