Configuring outbound mail / notification providers in tools (just like any other configurations) should be easier as you move higher up the application layer (Think configuring sendmail command line program vs...
One of the usual ways of developing web services – especially in organizations where Java is already being used – is to expose the java code as web services as part of SOA enablement. Converting code to a service is an example of bottom up development in SOA World and we are going to understand this using a simple Hello World Bottom Up Java Web Service using JDeveloper
Contents of this article are
- Textual Description
Bottom Up Java Web Service Development Video
Video of bottom up java web service development using JDeveloper is available below and also at our Youtube channel.
Creation of JDeveloper Project and Hello World Code
Creation of the JDeveloper project with a simple Hello world java class is a straight forward process. Steps involved to get this done are:
- Create JDeveloper project by right clicking in the workspace and selecting new project.
- Enter a name for the project and select Java and Web Service technologies to the project
- Accept rest of the defaults and click Finish.
- In the empty project created, create a new Java Class called Hello World – include Main method in the generation window so that you can test out the java class locally.
- Modify the generated class to add a simple sayHello function which takes a simple String name as input and returns a String as output after concatenating “Hello ” to the name. This means that if the name “ExpertzMe” is given as input, output from the function would be “Hello ExpertzMe”
- Save all files and test the java class by right clicking the java class and selecting run.
Exposing Java code as a web service
JDeveloper provides a wizard to automate creation of java web services. Steps involved to create java web services are:
- Right click the java class in the application navigator and select the option to create web service
- The wizard provides you various options to configure like
- Select the library used to generate web service
- Selecting the details of the service like SOAP versions, web service types
- Selecting additional options to add service handlers
- Attaching policies to the service, etc
- Accept the default options and click Finish to generate the web services.
Executing the service in JDeveloper
JDeveloper comes with a default integrated web logic server, which could be used for testing the web services (or java applications) in the developer machine itself. For our example, we will execute the service locally using the embedded integrated web logic server. Steps to achieve this are:
- Right click the service in the application navigator and select Run
- Select the option to run the service in WLS
- Wait for the weblogic server to come up and display the web service end point URL in the log window
- Copy paste the URL onto the browser window and add ?wsdl to the end of the URL. This should show you the generatd WSDL for your service.
- Click the end point URL in JDeveloper itself – which opens up the HTTP Analyzer window
- Enter the name value in the arg0 section as ExpertzMe
- Click the Send Request button to invoke the service and observe that you receive “Hello ExpertzMe” as response.
- Click on the HTTP content tab to see the entire SOAP payload exchange
Some of the things to conclude from this example are:
- JDeveloper provides multiple wizards to automate the Java Web service creation process
- You can configure many options like library to use, policies to configure, etc as options in a wizard to help with rapid development
- JDeveloper comes with built in integrated web logic server to help with running and testing of the code by the developer locally
- HTTP analyzer tool is provided by the JDeveloper to help you with quick execution and validation of web services