Create a new XML Data Control
Click New
in the File
menu to open the New Gallery
panel. Select the XML Data Control
from the Data Controls
folder under Business Tier
.
When using JDeveloper 11, you might need to switch to the All Technologies
tab first.
This will open a dialog to configure your XML Data Control. In this tutorial we are going to invoke a demonstration web service we host on the public internet that returns the SOAP/XML payload we need. The XML Data Control offers a number of different providers to get the XML which includes a static (test) file, a JSF EL expression, or you could implement your own provider that needs to somehow fetch the XML. More on that in the Developer's Guide.
For now, just enter the following details:
Item | Value |
---|---|
Name | HrDeptEmpDC |
Package | org.adfemg.xmlsample |
Runtime Schema | http://xmldc-sample.appspot.com/HR.xsd |
Design Schema | No need to specify this. This is only needed for rare cases where JDeveloper needs to fetch the XSD from a different location at design time than WebLogic at runtime |
Schema Root | DepartmentEmployeesResponse |
Data Provider | Web Service . |
Close the dialog to complete the wizard. The ADF XML Data Control extension has setup your project to use the ADF Binding layer and added the necessary libraries to your project.
Click the Refresh button in the Data Controls panel to force JDeveloper to reload the data control structures.
For the data control to actually work at runtime we still need to tell it a bit more about the web service. The XML Data Control is highly flexible by plugging in different providers. More on that in the full Developer's Guide, but for now we just need to focus on further configuring the web service data provider. All of this is done in the DataControls.dcx
file that defines the data controls. In JDeveloper 12 this should already have been opened after creating the data control, but in JDeveloper 11 you have to open this yourself from the Application Sources.
Switch to the source view of the DataControls.dcx editor and make a number of changes:
- Rename the dc-operation in the definition node, change the default 'getXML' to 'getDeptEmps'.
- Change the
endPointUrl
parameter value tohttp://xmldc-sample.appspot.com/HumanResourcesService
- Remove the entire
parameter
XML element forendPointConnection
- You can remove the
soapAction
element as our demo service doesn't need it, but you might need this when invoking other web services. The requestElement contains the actual SOAP request that needs to be sent to the server. We replace the
CDATA
content with our Request:<xml-parameter name="requestElement"> <!-- add service request XML (SOAPBody child) within CDATA for proper namespace handling --> <![CDATA[ <hr:DepartmentEmployeesRequest> <hr:departmentId>30</hr:departmentId> </hr:DepartmentEmployeesRequest> ]]> </xml-parameter>
You should end up with the followingdefinition
node (under theSource
node):
<definition xmlns="http://adfemg.org/adfm/datacontrol/configuration" schema="http://xmldc-sample.appspot.com/HR.xsd" schema-root="DepartmentEmployeesResponse" dc-operation="getDeptEmps"> <data-provider class="org.adfemg.datacontrol.xml.provider.data.WSDataProvider"> <parameters> <parameter name="endPointUrl" value="http://xmldc-sample.appspot.com/HumanResourcesService"/> <parameter name="soapVersion" value="1.1"/> <xml-parameter name="requestElement"> <![CDATA[ <DepartmentEmployeesRequest xmlns="http://adfemg.org/HR"> <departmentId>30</departmentId> </DepartmentEmployeesRequest> ]]> </xml-parameter> </parameters> </data-provider> </definition>
This completes the XML Data Control, if you refresh your Data Controls panel, you should see the operation name has changed: