Using Ant to inspect Connection Properties in WSDL Files that are generated by Oracle SOA Suite Adapters

Share this on .. Tweet about this on Twitter0Share on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on TumblrBuffer this page


Oracle SOA Suite comes with a collection of adapters that allow you to easily tap into a number of technologies from BPEL Processes or from ESB Services. Want to connect to a database, hook up to a queue or access your E-Business Suite: create an adapter for it with a WSDL interface from within JDeveloper by simply running a wizard.

Logical Connection Names

All adapters, whether these are used to connect to an FTP server or access an MQ-Series queue, use logical connection names or JNDI names that must be specified at design time. At runtime, the adapter framework uses these JNDI names for looking up the physical connection data from configuration files. This mechanism works well. It ensures that the software remains unchanged when dragging it through the various stages of the software development life-cycle process: from QA to SIT, to UAT and finally Production only the environment-specific configuration files have different data. Obviously, developers are required to stick to the naming conventions for the logical connection names.

Risky business

Unfortunately, for ‘convenience’ Oracle decided to place physical connection data in the generated WSDL files at design time. When the system is not able to obtain the connection details from the configuration files using the JNDI name, it will use the so called ManagedConnectionFactory or MCF properties from the WSDL instead. Risky business that may cause undesirable behavior: if there is a misconfiguration the service may connect to an instance that was specified at design time without you knowing that. I prefer a clear error on which a system administrator can act appropriately by fixing the connection details in the proper configuration file. Hence, as a rule, the MCF properties need to be removed from the generated WSDL files afterwards. For inspection of the connection properties in the WSDL files I created a simple Ant script. 


My initial requirement is simple: I want an overview of the connection data for all WSDL files in the project. Typically, these are listed in the WSDL files in the following format:

    <!-- Your runtime connection is declared in
        These 'mcf' properties here are from your design time connection and 
        save you from having to edit that file and restart the application server
        if eis/DB/HR is missing.
        These 'mcf' properties are safe to remove.
    <service name="ReadDptData">
        <port name="ReadDptData_pt" binding="tns:ReadDptData_binding">
            <jca:address location="eis/DB/HR"

Now, I want to check the contents of the <jca:address> element for each file. In a project I am currently working on that literally means plowing through hundreds of files. Hence, I need a utility that automates that tedious task for me. Since we already use Ant extensively, e.g. for deploying BPEL Processes and ESB Services, the utility is implemented as an Ant build script.

Loop Constructs and XML Tasks in Ant

Out of the Apache box, Ant does not come with looping constructs. Luckily the Ant-Contrib project provides very useful extensions to Ant among which is a foreach task that allows looping over a set of files. Subsequently, for each file I want to display the contents of of the <jca:address> element. Applying a simple XPath expression should do the trick. That is possible using the yet another Ant extension, XMLTask. Putting it all together results in the following script:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project name="QA" default="list-connection-data-in-wsdl-files" basedir="."&gt;
&lt;!--  QA Utilities for SOA components --&gt;
    &lt;property environment="env"/&gt;
    &lt;property name="server-src" value="${env.SOA_PROJECT_HOME}/work"/&gt;

    &lt;taskdef resource="net/sf/antcontrib/"&gt;
        &lt;pathelement location="${env.SOA_DA_HOME}/lib/ant-contrib-1.0b3.jar"/&gt;

    &lt;taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"&gt;
        &lt;pathelement location="${env.SOA_DA_HOME}/lib/xmltask-v1.15.1.jar"/&gt;

    &lt;target name="list-connection-data-in-wsdl-files"&gt;
      &lt;foreach target="list-connection-data-in-wsdl-file"
        &lt;path id="src.path"&gt;
          &lt;fileset dir="${server-src}"&gt;
            &lt;include name="**/*.wsdl"/&gt;

    &lt;target name="list-connection-data-in-wsdl-file"&gt;
      &lt;echo message="File name: ${source-file}" /&gt;
      &lt;xmltask source="${source-file}"&gt;
        &lt;copy path="descendant::*/:service/:port" buffer="connect-data-buffer"/&gt;
        &lt;print buffer="connect-data-buffer"/&gt;


When using XPath expressions in XMLTask Ant targets, like descendant::*/:service/:port in this case, the colon character is used by XMLTask to deal with local namespaces in the WSDL file. As far as I know, there is no way to pass on namespaces data to XMLTask (I confess that I did not spent a lot of time investigating). XPath expressions /:service/:port/:address and /:service/:port/jca:address do not return the required results.

Room for improvements

The script that is provided here suits my needs. But as always there is room for improvements. For one, when it does not find a <jca:address> element it reports that whereas in that case we could opt for not even mentioning the file. Furthermore, the script could be extended to automatically remove all but the location attribute from the <jca:address> element. For that purpose, XMLTask provides options for manipulation of XML documents.

Share this on .. Tweet about this on Twitter0Share on LinkedIn0Share on Facebook0Share on Google+0Email this to someoneShare on TumblrBuffer this page

About Author

Comments are closed.