您的位置:首页 > 其它

Adding a custom method in an ADF BC Service Interface – update of a single attribute in a selected r

2014-05-21 10:48 381 查看




Adding a custom method in an ADF BC Service Interface – update of a single attribute in a selected row

 3
BY LUCAS
JELLEMA ON
DECEMBER 30, 2010 ·GENERAL, JAVA
EE/JAVA, ORACLE, ORACLE
ADF, SOA & MIDDLEWARE

The article “Quickly creating, deploying and testing a WebService interface for ADF Business Components” (http://technology.amis.nl/blog/9726/quickly-creating-reploying-and-testing-a-webservice-interface-for-adf-business-components)
that I recently published describes a way of very rapidly creating the HRService Web Service – an ADF BC driven WebService on top of the EmployeesView ViewObject that exposes the EMPLOYEES table in the HR schema through the Employee EntityObject. However,
that article’s true purpose is to show how to create the deployment profile and deploy and test this service, either on the integrated WLS or on a standalone WebLogic Server, in the easiest way possible. This article is an extension of the previous one: it
demonstrates how to extend the Service Interface with a custom method (or an operation in terms of WebServices).

As it happens, I required an operation for updating just the salary of an Employee. I will show how I create a custom method in the Application Module’s implementation class, how I added this method to the Client Interface of the Application Module and subsequently
to the Service Interface. After redeploying – using the same deployment profile that was created previously – we can test the updateSalary method as a new operation in the WebService.

Open the Application Module editor. Go to the Java tab and click on the edit (pencil) icon. Check the checkbox to Generate Application Module Class HRServiceImpl.



Then press OK.

Click on the hyperlink for HRServiceImpl. The java editor opens for class HRServiceImpl.

Implement method updateSalary. The method takes two integers – the employee identifier and the newly awarded salary – and returns a String as result.



The code will first leverage the EmployeesView1 ViewObject to get hold of the employee’s Row for the employeeId (the primary key for this ViewObject). When found, the Salary attribute is updated, and the result string is composed.

?
With the method now available in the ApplicationModuleImpl class, we can add it to the Client Interface.

Back in the Java tab for the Application Module, click on the edit (pencil) icon to edit the Client Interface:L



In the Client Interface editor, select the new method updateSalary to add to the Client Interface.



Click on OK.

With the Client Interface appropriately extended, we can now edit the Service Interface likewise.

Go to the Service Interface tab for the Application Module. Click on the icon to edit the Custom Methods for the Service interface.



Select the updateSalary method. Then press OK.



The definition of the Service Interface for Application Module HRService is now extended with the updateSalary salary, that will be exposed as Operation updateSalary in the Web Service.



Redeploy the application using the application deployment profile discussed in the prequel to this article.

Then open your browser to test the web service, in my case at: http://localhost:8001/HRDataServices/HRService.


Select operation updateSalary that is now available for the first time. Specify employee identifier and new salary. Then press the Invoke button.

The response from the WebService appears:



When we check the database, we will find that the salary has indeed been updated:



Through Custom Methods, it becomes very easy to provide dedicated, fine grained operations (or composite, very coarse grained operations)  in the WebServices published for our Application Modules.

Related posts:

How
to refer to an Attribute in the Currently Selected Table row in an ADF Faces page – implementing a Generic Row Reader

Quickly
creating, deploying and testing a WebService interface for ADF Business Components

Oracle
& JDBC – Passing a 'table of custom object type' to a stored procedure – implementing efficient single round trip data exchange (part two of an ADF application on a PL/SQL API)

JHeadstart
ADF Generation with Custom Templates – using custom properties when none are available

ADF11gR2:
Plotting custom locations on a Thematic Map using a GeoCoder Service
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐