UseCase Description
One of the most common usecases in WS is passing complex Input parameters, but incase if the user wants to pass the multiple occurence of the same complex Input parameter type, how to achieve this in WSDC ?.
This blog explains about passing the multiple complex Employee records to the WebService from the WSDC via the Backing Bean
Let us Consider an ADFBC Component which contains an Employees Entity, now the user can select multiple employee records from the page containing List of Employee records and post it to the WebService.
Implementation Steps
1. Create an Web Service which takes the Input Argument as ArrayList of Employee Object and returns the ArrayList .
The Sample SOAP Request/Response looks like as shown below ,
Here we can observe that the the occurence of the "emp" object is dynamic which contains different employee records with three attributes (empEmail, empId, empName).
SOAP Request
<ns1:addemp>
<emp>
<empemail>SLROCK</empemail>
<empid>101</empid>
<empname>ShawnRock</empname>
</emp>
<emp>
<empemail>OKOKHLO</empemail>
<empid>202</empid>
<empname>OnkBank</empname>
</emp>
</ns1:addemp>
SOAP Response
<ns2:addempresponse xmlns:ns2="http://project1/">
<return>
<empemail>SLROCK</empemail>
<empid>101</empid>
<empname>ShawnRock</empname>
</return>
<return>
<empemail>OKOKHLO</empemail>
<empid>202</empid>
<empname>OnkBank</empname>
</return>
</ns2:addempresponse>
3. Drag and Drop the EmployeesView1 node from the DC palette onto the page1.jspx as ADF Table.Ensure that the page1.jspx is bounded to a Backing Bean
4. Create a WSDC using the WSDL url of the service deployed to the server
5. Create a Command Button in page1.jspx and bound it to an Action Listener method in the Backing Bean . The Method is used to retrieve the records selected by the user from the page1.jspx and post it to the WS.
BindingContainer bindings = getBindings();
RowKeySet selectedEmps = getT1().getSelectedRowKeys();
Iterator selectedEmpIter = selectedEmps.iterator();
DCBindingContainer bx = (DCBindingContainer) getBindings();
DCIteratorBinding empIter = bx.findIteratorBinding("EmployeesView1Iterator");
RowSetIterator empRSIter = empIter.getRowSetIterator();
6. This is Achieved by marshalling the selected data as an Employee Objects and adding them to an ArrayList.
ArrayListal = new ArrayList (); while(selectedEmpIter.hasNext()){ Key key = (Key)((List)selectedEmpIter.next()).get(0); Row currentRow = empRSIter.getRow(key); al.add(new Employee((String)currentRow.getAttribute("FirstName"),(Integer)currentRow.getAttribute("EmployeeId"),(String)currentRow.getAttribute("Email"))); }
OperationBinding operationBinding = bindings.getOperationBinding("addEmp");
operationBinding.getParamsMap().put("emp",al);
operationBinding.execute();
8. In page2.jspx, Drag and Drop the Return type of the WSDC method as ADF Table9. Run the Page1.jspx, select the list of Employee records and click on the post to webservice button
10. In the Next Page we can observe that the selected 4 records are posted to the WebService

