JDeveloper allows you to expose Application Modules as Web
Services. The Service Enabled Application Module exposes the View Objects,
Custom Methods, Built-In Data Manipulation Operations, and Specialized Find
methods based on named view criteria to be used by the client.
In this blog, I will cover
- Exposing
Application Module as SOAP Service. In this, expose
- View
Object
- Built-In
Data Manipulation Operations on View Object
- Custom
methods
- Deploying
Service locally in the Integrated Weblogic Server
- Deploying
Service in the Standalone Weblogic Server
- Testing
the Service operations
Securing this Web Service will be discussed in my next blog...
Created a Fusion Web Application project using Departments
and Employee tables of HR schema and it is structured like below.
I have created one method in EmployeesAMImpl.java. It
takes DepartmentId as input and returns DepartmentName.
We are all done with code part. Now let’s quickly
create service interface and expose the web service.
Exposing
Application Module as Service Interface:
Open EmployeesAM and Web Services tab. Click on green +
icon.
It opens up Create Service Interface popup. In
Step 1, we can set Web Service Name, and Target Namespace, enable option to
generate asynchronous methods, by default it supports synchronous service
methods. Also, generates control hint operations.
In Step 2, if we have any custom methods defined in
Application Module then we can expose these methods to service interface.
Select the method which you want to expose on Web Service and
shuttle them to right side window. If ‘Include Warnings in Return Service Data
Object’ is not selected, no informational messages will be returned with the
service response. This option is not enabled when method is returning view rows
or list of view rows. When the method returns view rows, the underlying view
object determines whether the method supports warnings or not. When this option
is enabled on View Object, JDeveloper generates appropriate wrappers as the
return objects, and the wrappers contain the actual method return and the
informational messages.
In Step 3, we can expose some built in methods on the view
object. First shuttle the View Objects to right and highlight it to enable the
built-in methods. Choose the operations which you want to expose. Also, in View
Criteria Find operations tab, you can add view criterias for find operations.
Click on Finish to create service interface and all required
files.
Project now looks like below.
In order to have a nicer looking URL for the WebService
endpoint as well as a better looking name for the application itself, we will
open the Project Properties editor for the Model project, and open the Java EE
Application node.
Deploy WebService
locally in a Integrated WLS Server:
This is easier than deploying on a standalone application
server instance. Run EmployeeServiceImpl.java file to deploy and test this Web
Service.
The Integrated WLS server is started, when not already
running and the ADF BC application is deployed on it. The Application’s Context
Root and the Name of the Service Interface, together with localhost:7101, make
up the endpoint URL for the Web Service.
Create the
standalone application server:
Go through the page to know how standalone application server can be created.
There is one important setting that you need to apply to the
WLS domain that you will be deploying the ADF BC Web Service to. This setting
is required to prevent the “Null Password given” error message that otherwise
results when we access the web service. Simply put this setting instructs the
WLS domain to accept passwords in deployed application.
Open the setDomainEnv.cmd or setDomainEnv.sh file –
depending on your operating system – in the directory [WLS_HOME]\user_project\domain\[your
target domain]\bin and add the following line after the first occurrence of set
JAVA_PROPERTIES.
"set JAVA_PROPERTIES=%JAVA_PROPERTIES%
-Djps.app.credential.overwrite.allowed=true"
Pre-Requisites to
deploy your application to standalone server:
Next is to see how Service Interface can be deployed on a
standalone application server. Let’s prepare it for deployment. i.e., create
the deployment profiles, setting up the standalone and et.c.,
Right
click on Model project and chose Project Properties.
Chose Deployment in left region and click New icon in
right side region.
Select Archive Type as Business Components Service
Interface, provide some name to the Deployment profile and click OK. Deployment
Profile is created like below.
If you happened to deploy your application to
standalone earlier, then you can skip this step. This step is to create the EAR
deployment profile. Open Application Properties window.
Chose Deployment in left region, highlight application
deployment profile and click Edit.
In the EAR Deployment Profile editor, select the node
Application Assembly. Check the checkbox for Middle Tier in the EmployeeService
deployment profile (of type Business Components Service Interface) that we have
previously created. Click OK.
Back in the Deployment page for the Application Properties, make sure that the
checkbox Auto Generate and Synchronize weblogic-jdbc.xml Descriptors During
Deployment is unchecked. Click OK.
Deploy EAR to
Standalone application Server:
We are now ready to deploy the application to a standalone
Weblogic Server domain. Note that I am assuming that you already have
configured a connection to the target WLS domain. We will use that connection
for the upcoming deployment.
Open
the context menu for the Application – the same dropdown we used for creating
the deployment profile for the application. Open the submenu Deploy and Select
the SOAPEmpApp_application1 deployment profile.
The Deployment Wizard appears.
In the first step, elect to deploy to Application Server:
Press Next. In the 2nd step, select the
connection to the target Application Server.
Press Next. Select the radio button Deploy to selected
instances in the domain and select the target server(s) to which you want to
deploy the ADF BC Service application. Make sure that the radio button Deploy as standalone
Application is selected.
Press
Next. The Summary appears. After a final review, press Finish to start the real
deployment.
Testing the Web
Service:
You
can open that URL in your browser. Observe that sync and async built-in methods
and custom methods are available on Service Interface.
Let’s try testing a couple of operations.
Chose getEmployees operation, input EmployeeId as 120 and
click Invoke.
It returns the response like below.
Let’s test the custom method. Choose getDeptName from Operation
drop down. Enter deptId as 70 and click Invoke button.
It gives the response like below with Department Name.
References:
Happy learning... :)