The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFm
    April 14, 2011

How to access the WS SOAP message using WS DC

Frank Nimphius
Master Principal Product Manager

A frequent requirement is to access the SOAP message of a service to e.g. set SOAP header information required by a service for passing license keys or authentication information. In Java, the SOAPMessage class gives you access to the SoapPart, SOAPEnvenlope, SOAPBody and the SOAPHeader using code like shown below:

SOAPPart       sp = soapMessage.getSOAPPart();

SOAPEnvelope   se = soapMessage.getEnvelope();

SOAPBody       sb = soapMessage.getBody();

SOAPHeader     sh = soapMessage.getHeader();

See: http://download.oracle.com/javaee/1.4/api/javax/xml/soap/SOAPMessage.html

To access incoming and outgoing SOAP messages when using the Oracle ADF WS Data Control, you need to override the default SOAP provider that is configured in the DataControls.dcx file of the WS Data Control project.

      <definition xmlns=
                  name="PojoWsDC" version="1.0"                        provider=

To change the provider class, extend the default “SOAPProvider” provider class as shown in an example below

public class CustomSOAProvider extends SOAPProvider {
    public CustomSOAProvider() {

    //expose protected method to public
    public void handleRequest(SOAPMessage soapMessage) throws AdapterException   
    //Expose protetcted method to public
    public void handleResponse(SOAPMessage soapMessage) throws AdapterException   

Change the DataControls.dcx configuration to use your custom provider, for example

  <definition xmlns=
              name="PojoWsDC" version="1.0"

You can access the custom SOAP provider from a managed bean, which also allows you to expose its functionality to Expression Language. Before you can access the custom SOAP provider from a managed bean, you need to know the name of the Data Control that is used to access the Web Service. The name of the Data Control is defined in the DataControls.cpx file where it can be looked up. The file is located in the ViewController project.

The Data Control name can also be looked up in the Data Controls palette. This however requires that the name indicates that it accesses a Web Service Data Control, as otherwise it will be hard to tell.

You use the following code to access the custom SOAP provider from Java in a managed bean:

BindingContext bctx = BindingContext.getCurrent();
DataControl dc = bctx.findDataControl("PojoWsDC");    
WSDataControl wsdc = (WSDataControl) dc.getDataProvider();      
CustomSOAProvider customSoapProvider =
                  (CustomSOAProvider)  wsdc.getProvider();

If you are using JDeveloper or later, because the SOAPProvider class is in an ADF internal package, you need to be aware of the ADF internal Java class audit rule and how to switch it off:


But why do you need to create a custom SOAPProvider extending the default provider?

The default SOAPProvider class has the handleRequest and handleResponse methods defined as protected for security reasons. To make these methods available for the ViewController to use, you need to expose them as public methods, which is what the custom SOAPProvider class primarily is for.

Note: I filed an ER for a public access to the SOAPProvider class.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.