Friday, 1 August 2014

Passing Custom SOAP Headers in ADF Mobile

This document shows how custom SOAP Headers can be passed in ADF Mobile to make web service calls. 

JDeveloper Version - with Mobile support
For the purpose of this demo, I am using a basic Hello service secured with the OWSM policy ‘oracle/wss_username_token_service_policy’. Additionally, the service responds to only those clients who send a custom SOAP Header with value ‘ClientABC’. Any other value in the header will receive “Invalid Client---Access denied.” as response. You may create the service on similar lines or use the attached service from here (Note that this service has been created in build)

  1. Create a new ADF Mobile application.
  2. In the ApplicationController project, create a data control for the WSDL URL of the above service.
  3. Since we need to pass some additional header information in the SOAP Envelope, we need to implement the method public SoapHeader[] getAdditionalSoapHeaders() in our own way.
To do this, in the ApplicationController project, create a new Java Class. Call it ‘’. Let the class extend SOAPProvider from the package oracle.adfinternal.model.adapter.webservice.provider.soap.SOAPProvider.

Implement the getAdditionalSoapHeaders() method as shown:

    public SoapHeader[] getAdditionalSoapHeaders() {
        System.out.println("In getAdditionalSoapHeaders");
        SoapHeader header[] = new SoapHeader[2];
        SoapHeader token = null;
        SoapHeader user = null;
        SoapHeader pass = null;
        header[0] = new SoapHeader(
                    "","ClientName","ClientABC"); //specify the namespace, tag name and the client value
        header[1] = new SoapHeader(
        token = new SoapHeader(
        user = new SoapHeader(
        pass = new SoapHeader(
        return header;
In my case, a valid request structure was as below. Thus, the above code was based on this structure.

<?xml version = '1.0' encoding = 'UTF-8'?>
<env:Envelope xmlns:env="" xmlns:ns1="" xmlns:ns2="http://project1/"> 
<ClientName xmlns="">ClientABC</ClientName>

  1. Also, open the DataControls.dcx file and search for provider="oracle.adfinternal.model.adapter.webservice.provider.soap.SOAPProvider". Change this default provider to point to the Provider class we just implemented. In this case, change the line to provider=" application.CustomHeaderClass”.

   5. D&D the method in the DC to an AMX page along with an output text box. If you invoke the method and check the request in the analyzer, you should be able to see the headers being passed.


No comments:

Post a Comment