In this blogpost I will explain the options you have when you use JDeveloper to generate a web service based on a WSDL, so called top down or contract first. In my previous blogpost I showed you the bottom up approach. This works great but it can lead to a ugly WSDL which it is not so great for interoperability. Off course you can control it all with some web service annotations but then you really need to know what you are doing.
Here is an example of a bottom up WSDL. It matches with the java methods
Let's change it to this and use this WSDL in JDeveloper.
Before we can start lets copy the WSDL and its XSD to the project folder. This way JDeveloper can detect it.
In JDeveloper we can choose for Java Web Service from WSDL.
We can select our WSDL from the listbox and in this dialog we can choose for some important options.
First we can choose Java or for EJB 3.0 as Service Type. With Java as Service Type JDeveloper will add the Web Service as servlet to the web.xml. This is not the case with EJB.
With EJB as Service Type you will get transaction, security support, can use interceptors and the timer service. If you enable the Add Service Endpoint Interface option and add an Remote annotations to this interface you can call the Remote interface of this EJB with RMI (t3:) besides invoking this Web Service with HTTP.
The Service Endpoint Interface (SEI) is a Java interface that declares the methods that a client can invoke on the service. It provides the client's view of the web service and hiding the implementation from the client.
Provide the package names for the web service and the java types.
This will generate the following code. We need this JAXB code in completing the service implementation.
The generated service interface.
The service implementation.
To complete the service we can for example inject an EJB and include the JAXB ObjectFactory.
And the contract first web service is finished.
Thank you for this useful post. Still one question, how to deploy this Web Service to WebLogic server?
ReplyDelete