WSDL File

Web services have a description language known as WSDL, which is used to describe in a nutshell what the web service does and gives the client all the information required to connect and use the web service

There are two types of WSDL files, They are Abstract WSDL, Concreate WSDL.

Abstract WSDL will be created at design time where as Concrete WSDL will be created after the deployment. Concrete WSDL includes <Binding> and <Service> elements which are not present in abstract WSDL.

WSDL Elements:

  • wsdl: types
  • wsdl: message
  • wsdl: portType
  • wsdl: binding
  • wsdl: service

10

Types: Defines the (XML Schema) data types used by the web service. eg : Employee XML element data type is defined under types.

Messages: Defines the data elements for each operation. eg CreateEmployeeRequest , CreateEmployeeResponse.

PortType: Defines the operations (functionalities) and messages that this web service provides. Eg. Operation – createEmployee , input – CreateEmployeeRequest, Output – CreateEmployeeResponse  is defined in this section.

Binding: Defines the protocol and data format. SOAP binding of the webservice is providing here. Other bindings are ftp, jca etc..

Service: Provides the location (endpoint) where this service is available. https://soadev.orgA.com/services/EmployeeService

Sample WSDL File:

11

 

Advertisements

SOAP and REST

This post covers features of SOAP and REST and basic differences between them.

SOAP

REST

  • SOAP stands for Simple Object Access Protocol
  • It is an XML based web service
  • Adds a layer on top of the application protocols. HTTP is the widely used application protocol.
  • SOAP is considered heavy weight as it provides significant pre-build extensibility in the form of the WS* standards through additional layer.

1

  • Request includes HTTP header, SOAP Envelope (which includes SOAP Header, SOAP Body (which includes XML message))
  • As it has additional layer, it supports attaching files in the request which should be in base64 bit format.
  • It provides more security than REST.
  • REST stands for Representational State Transfer
  • REST typically supports all types of text data formats. Widely used formats are XML and JSON
  • Uses HTTP protocol only. No another layer on top of HTTP protocol.
  • REST is light weight as it leverages HTTP transport and uses all HTTP Action Verbs (POST, GET, PUT, DELETE)

2

 

  • Request includes just HTTP header and XML/JSON message.
  • It doesn’t support attachment of files in the request.
  • REST provides security like token based, but comparatively REST security is less than SOAP.

Sample SOAP Request:

A SOAP Message is encoded as an XML document, consisting of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element is sub element of Body is used for reporting errors.

5.png

 

SOAP Envelope with SOAP Header.

3

Sample SOAP Response:

6.PNG

Sample REST Request in XML:

7

Sample REST Response in XML:

8

Sample REST Request in JSON:

9

Testing of SOAP/REST web service Requests can be done using SOAP UI tool.

Invoking REST webservice from JQuery using an AJAX call

Below code helps you to understand how we can Invoke a REST web service on click of a button using JQuery and AJAX.

Note: In Java you can Invoke REST web service using ApacheHTTPClient library.

HTML File:

<!DOCTYPE html>
<html>
<head>
<sscript type=”text/javascript”
src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js”></script&gt;
<sscript type=”text/javascript”>
$(document).ready(function () {
$(“#mybutton”).click(function () {
alert(‘welcome’);

$.ajax( {
type : “GET”, url : “http://services.groupkt.com/country/get/iso2code/IN&#8221;, dataType : “json”, success : function (data) {
alert(“Reading Msg: ” + data.RestResponse.messages);
alert(“Reading Name: ” + data.RestResponse.result.name);
}
});

});

});
</script>
</head>
<body>
<button type=”button” id=”mybutton”>Invoke REST WS</button>
</body>
</html>

Sample REST Services (thanks for making them available to developers for testing purpose):

http://www.groupkt.com/post/c9b0ccb9/country-and-other-related-rest-webservices.htm
http://services.groupkt.com/country/get/iso2code/IN
http://services.groupkt.com/country/get/all
http://rest-service.guides.spring.io/greeting

REST_invoke

Invoke a WebService with the Inserted Rows data of Excel sheet in ADF-DI:

In ADF-DI you don’t have any direct option available to get the control over all the inserted rows to invoke WS (Web Service). So you must implement it with the help of programmatic approach.

First what you need to understand is, If you want to upload 100 records of data from Excel sheet to DB, first you must set a property [InsertBeforeRowActionID : ‘CreateInsert‘] which means before reading each row of data, a new empty row object is created and the data of that row is stored into that row object cache. The same thing happens for all the rows. Once all the rows of Excel sheet are read, the cached data has to be committed to DB. So set the property [CommitBatchActionID: Commit] which inserts the cached data to DB.

The above properties must be set to upload data to DB from Excel sheet. To achieve this your page definition file must contain the bindings [tree binding, Commit, CreateInsert bindings]

To get the Handle over the Excel sheet data, you must set below proprieties.
Property [InsertBeforeRowActionID : ‘eachRowInvokeAM‘] which is being used to Invoke a custom method where current row data can be read and stored to a List. This will repeat for all the rows.
Then set the property [SuccessActionID : afterAllRowsInvokeAM] for a ribbon command ‘Update‘. This triggers the custom method ‘afterAllRowsInvokeAM’ after successful Insert/Update to DB. In this custom method, you can work with the list which has the data of all rows inserted in the Update operation. Using this data you can Invoke a Web Service.

You must write your custom methods in AMImpl class. ADF12c supports only AMImpl class methods, where as ADF11g supports AMImpl & VOImpl class methods to invoke.

Eg: Let’s take an example, where we insert a record to Departments table. And after all the rows got inserted to DB from ADF-DI Excel sheet a webservice should be invoked with the inserted data as input. For this set the below properties.

InsertBeforeRowActionID : ‘CreateInsert’
InsertBeforeRowActionID : ‘eachRowInvokeAM’
InsertRowEnabled: True
CommitBatchActionID: Commit
RibbonCommand- Update -> SelectActionSet -> ActionOptions -> SuccessActionID : afterAllRowsInvokeAM

Custom methods given above are [‘eachRowInvokeAM’, ‘afterAllRowsInvokeAM’] are mehtods created in AMImpl class .
Another class also created ‘Dept’ which is a Pojo class with the column names as variables and having parameterized constructor.
In the AMImpl class, a list is created of type ‘Dept’ pojo class. And the parameterized constructor is being invoked to insert the department type object to the list. Two custom methods are created in it [‘eachRowInvokeAM’, ‘afterAllRowsInvokeAM’] and are exposed and then added to the page definition file as method bindings. During each row insert ‘eachRowInvokeAM’ will be invoked and that row data in inserted to the List. Once the commit operation is susccessful another method ‘afterAllRowsInvokeAM’ will be invoked where the list data is read and used as input to Invoke the webservice.

The page definition file should be:

ADF-DI_1.PNG

Excel properties should be:

ADF-DI_3

ADF-DI_2

 

AmImpl.java:


package model;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import java.net.HttpURLConnection;
import java.net.URL;

import java.util.ArrayList;
import java.util.List;

import model.common.AppModule;

import oracle.jbo.Row;
import oracle.jbo.server.ApplicationModuleImpl;
import oracle.jbo.server.ViewLinkImpl;
import oracle.jbo.server.ViewObjectImpl;

public class AppModuleImpl extends ApplicationModuleImpl implements AppModule {

/* Custom Code */
List dept = new ArrayList();
public void eachRowInvokeAM(){
System.out.println("Entered before Upload..");
System.out.println("row count:"+getDepartmentsView1().getRowCount());
Row r = getDepartmentsView1().getCurrentRow();
System.out.println(r.getAttribute("DepartmentId"));
System.out.println(r.getAttribute("DepartmentName"));
System.out.println(r.getAttribute("LocationId"));
System.out.println(r.getAttribute("ManagerId"));

int deptId = Integer.valueOf(r.getAttribute("DepartmentId").toString());
String deptName = r.getAttribute("DepartmentName").toString();
int locId = Integer.valueOf(r.getAttribute("LocationId").toString());
int mgrId = Integer.valueOf(r.getAttribute("ManagerId").toString());

//adding current row to list
dept.add(new Dept(deptId, deptName, locId, mgrId));
}

public void afterAllRowsInvokeAM() {
System.out.println("after Insert success..");
System.out.println("rows inserted:"+dept.size());
for(int i=0; i< dept.size(); i++){
System.out.println(dept.get(i).getDepartmentId());
System.out.println(dept.get(i).getDepartmentName());
System.out.println(dept.get(i).getLocationId());
System.out.println(dept.get(i).getManagerId());
}
System.out.println("Now Invoking WebService");
try {
http_client();  // Invoke Webserive method
} catch (Exception e) {
}
}

public static void http_client() throws Exception {
System.out.println("Invoke service using direct HTTP call with Basic Auth");
String payload =
"\n" +
" \n" +
" \n" +
" \n" +
" INR\n" +
" USD\n" +
" \n" +
" \n" +
"";

httpPost("http://www.webservicex.net/CurrencyConvertor.asmx" + "?invoke=", payload);
}
private static String httpPost(String destUrl, String postData) throws Exception {
URL url = new URL(destUrl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
if (conn == null) {
return null;
}
conn.setRequestProperty("Content-Type", "text/xml; charset=UTF-8");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setFollowRedirects(true);
conn.setAllowUserInteraction(false);
conn.setRequestMethod("POST");

//byte[] authBytes = authStr.getBytes("UTF-8");
//String auth = com.sun.org.apache.xml.internal.security.utils.Base64.encode(authBytes);
// conn.setRequestProperty("Authorization", "Basic " + auth);

System.out.println("post data size:" + postData.length());

OutputStream out = conn.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
writer.write(postData);
writer.close();
out.close();

System.out.println("connection status: " + conn.getResponseCode() +
"; connection response: " +
conn.getResponseMessage());

InputStream in = conn.getInputStream();
InputStreamReader iReader = new InputStreamReader(in);
BufferedReader bReader = new BufferedReader(iReader);

String line;
String response = "";
System.out.println("==================Service response: ================ ");
while ((line = bReader.readLine()) != null) {
System.out.println(line);
response += line;
}
iReader.close();
bReader.close();
in.close();
conn.disconnect();

return response;
}

Dept.java:

</pre>
package model; public class Dept { int DepartmentId; String DepartmentName; int LocationId; int ManagerId; public Dept(int DeptId, String DeptName, int LocId, int MgrId) { //super(); this.DepartmentId = DeptId; this.DepartmentName = DeptName; this.LocationId = LocId; this.ManagerId = MgrId; } public void setDepartmentId(int DepartmentId) { this.DepartmentId = DepartmentId; } public int getDepartmentId() { return DepartmentId; } public void setDepartmentName(String DepartmentName) { this.DepartmentName = DepartmentName; } public String getDepartmentName() { return DepartmentName; } public void setLocationId(int LocationId) { this.LocationId = LocationId; } public int getLocationId() { return LocationId; } public void setManagerId(int ManagerId) { this.ManagerId = ManagerId; } public int getManagerId() { return ManagerId; } } 

Your Excel in Design Time:

ADF-DI_4.PNG

Your Excel at run time:

ADF-DI_5


After Click on Ribbon button ‘Upload’, all the rows inserted to DB and also a web service is invoked at back end.

ADF-DI_6

Hope the post is Informative!

AM Service Interface (Expose ADF BC as web services/ service Enabled data objects SDOs)

======================================================
PART – 1:
AppModule Service Interface webservice genearation [Expose ADF BC as SDOs service enabled daat objects]:
-> create ADF application with business components (EO, VO, AM)
-> write two custom methods in AppModuleImpl class and expose those methods to Client Interface.
-> double click AM -> Service Interface tab -> you can see three sections ‘service Interface for custom methods’, ‘service interface for view instances’, ‘Genearated files for Service interface’.
-> select required methods/view Instances of datamodel in respective sections. When you select a view instance, operations for that view isntance are displayed jsut beside to it and we can select what operations to enable for the view instance [oeprations as ‘update’ to edit the record of that view instance, ‘Find’ to retrieve the records from that view instance, Create, Delete, Merge, GetByKey, Process, etc..].
-> After selection, under AM a folder named ‘service interface’ will be created which contains webservice artifacts [AppModuleService.java, AppModuleServiceImpl.java, AppModuleService.wsdl, AppModuleService.xsd]
-> Deployment: create deployment profile for ‘[Business Components Service Interface]’. deploy [check Model projetc is checked and under which both ‘common’, ‘middletier’ selected for integrated weblogic, and only ‘middletier’ selected for deployment on servers]
-> Test the webservices from Weblogic EM console like the same way you test SOA webservices.
======================================================
Sample custom methods which you can expose in AM:
public void updateSalary(Number employeeId, Number salary){
Key key = new Key(new Object[] {employeeId});
Row row = this.getEmployeesView1().getRow(key);
row.setAttribute(“Salary”, salary);

try{
this.getDBTransaction().commit();
}
catch(Exception ex){
ex.printStackTrace();
}
// The above methods accepts EmpId, Salary as input and updates the salary for the given EmpId in DB
======================================================
Note: we need Oracle web services manager to define the security policy for AppModule Webservices(according to documentation B31974-05 section 11.2.13). So need to license Oracle SOA suite cos webservices manager comes under SOA suite. So without using SOA, if you want to expose webservice from ADF business components you can not proivde security to them.
These exposed websrevices will creates new AM configuration and uses AppModule pool for DB connection when invoked.
======================================================
References:
http://andrejusb.blogspot.in/2009/08/web-service-interface-for-adf-bc.html

For secured WS you can check this post – http://andrejusb.blogspot.com/2012/11/adf-mobile-secured-web-service-access.html This is about ADF Mobile, but Web Service part is about secured AM Web Service
====================================================== ======================================================
====================================================== ======================================================
====================================================== ======================================================
PART – 2:
In above we have exposed the ADF Business component services as webservice (service enabled data objects/SDO).
Now we can consume those ADF BC services from SOA applicaiton or from another ADF application also.
Now we are discussing on How to consume remote ADF BC services[AM methods, VOs] which are exposed as webservice in other ADF applicaiton.

Create a new ADF applicaiton. [In this applicaiton we create Service Enable Entity Objects, whcih means EOs are created based on SDOs (service enabled objects)]
create Entity object-> when creating EO uncheck defalut datasource selection ‘DB schema object’, check ‘Service Interface’, give the WSDL URL and select the Service ViewInstance from dropdown.
Run the AM, now you can create a record, update record, delete record.
EO based on remote VO exposed though webservice (Service enabled EOs) will be similar to EO based on DB. But Joins doesn’t work for this EO when you create EO based on VO exposed as webservice.
We can declare Business Events on Service-Enabled Entity Objects, it works same as declared on normal Entity Object.
You can see the attributes but you can see the query, as this EO will get data dynamically as this is based on webservice.
So this is how you can crete a EO from a VO based on remote applicaiton which is exposed through webservice.
Deployment: Here first you need to add the ‘applnname_common.jar’ library of exposed applicaion to this consuming applicaiton.
Give the service connection information in connectons.xml. Now you can deploy and test from EM console.
Note: The operations which you select for a view isntance during exposing AM, those will only be available for applications when consuming them.
———————————–
References: http://andrejusb.blogspot.in/2009/08/service-enabled-entity-objects-in.html
====================================================== ======================================================
====================================================== ======================================================
====================================================== ======================================================
PART – 3:
Creating Business Event and subscribing to that event in Oralce SOA.
Busieness Events allows the loose coupling. Busieness Events can be created from ADF BC or from SOA.
These Business Events can be subscribed in SOA composite using Mediator.

References:
http://andrejusb.blogspot.in/2009/08/business-events-and-adf-business.html
http://biemond.blogspot.in/2008/05/events-in-adf-bc-and-handled-by-soa.html

————–

-> Oracle ADF Functional Patterns and Best Practices
http://www.oracle.com/technetwork/developer-tools/adf/index-100668.html

-> Customizing and Personalizing an Application
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_18/jdtut_11r2_18.html

-> Oracle Fusion Applications
12c: https://docs.oracle.com/applications/falcm12/OADEE/title.htm
11.1.8: https://docs.oracle.com/cd/E48434_01/fusionapps.1118/e15524/gs_gs_e.htm#CDEHADGG