Reading WSDL


, ,

While SOA offers all the goodies of loose-coupling, it does require understanding of some basic concepts and formats.
SOAP and WSDL are the prime candidates (or culprits, depending on your view)

SOAP is just a protocol for passing information, important is WSDL.

A WSDL(Web Service Description Language) file defines the contract for web service. It is just like the menu in a restaurant or a table of contents of a book. It tells about what is offered.

Without wasting more time, lets just get to work – understanding WSDL.

A WSDL file may be provided to you or it can generally be accessed by appending “?wsdl” at the end of a web service address.

A WSDL file is best-read bottom-up. It consists of abstract as well as concrete parts. Important parts to focus are (concrete)-

  • wsdl:service – this is the tag which tells you about the name of the service. Consider it synonymous with class file.
  • wsdl:port or port – this tag tells about the place where you can connect to. There can be multiple ports. Each port will have an “address” element. The location attribute specifies the endpoint address of the service. Pay attention the binding attribute of the port.
  • wsdl:binding – this tag refers to the actual implementation of the service. It’ll be further up in the wsdl document. It contains the methods of the service.
  • wsdl:operation – this tag refers to the operations provided by the port. wsdl:operation will contain soap:operation or similar tag depending on the binding.
  • wsdl:input and wsdl:output – specifies the form of input/output. This is because it can be either literal or encoded.

Now focus on the Type attribute of the wsdl:binding, and trace it up in the document. It leads you to portType element. portType is the abstract part of the wsdl.

  • portType – is something like an Interface, in fact it is called as interface in wsdl 2.0. It’ll have a no. of operations.
  • operation – specifies input and output message variable types. These types are specified further up in the wsdl.

Call Oracle PL/SQL procedure with XMLType from Java using JDBC


, , , , ,

Recently I needed to call a stored procedure which had Oracle’s XMLType as IN and OUT parameters.

The first thing to do is add xdb.jar and xmlparserv2.jar file to your application lib. These contain the required class files for Oracle XML API. the jars can be found under your installation of oracle client lib folders. Also don’t forget to add oracle jdbc driver files – ojdbc6 or ojdbc14.

The code I setup was this –

XMLType reqInXml;
XMLType reqOutXML;
String atpInStr = "";
OpResponse output = null;

try {
   reqInStr = jaxbMarshalRequestToString(input);
   System.out.println("Input : " + reqInStr);
} catch (JAXBException ex) {
   logger.log(Level.SEVERE, null, ex);
} catch (IOException ex) {
   logger.log(Level.SEVERE, null, ex);

//input.getHeader().setNotes("THIS VALUE RETURNED BY FACADE : " + XXDS);
try {
   Connection con = XXDS.getConnection();
   //The IN parameter for stored proc is Oracle XDB XMLType
   reqInXml = XMLType.createXML(con, reqInStr);
   OracleCallableStatement stmt = (OracleCallableStatement) con.prepareCall("call DEMO_PROC.ProcessXMLRequest(?, ?, ?, ?)");
   stmt.setObject(1, reqInXml);

   //set out parameters
   stmt.registerOutParameter (2, OracleTypes.OPAQUE,"SYS.XMLTYPE");
   stmt.registerOutParameter(3, Types.INTEGER);
   stmt.registerOutParameter(4, Types.VARCHAR);

   int resultCode = stmt.getInt(3);
   String resultMsg = stmt.getString(4);
   System.out.println("result code : " + resultCode);
   System.out.println("result msg : " + resultMsg);
   if (resultCode == 101 || resultCode == 100){
      reqOutXML = XMLType.createXML(stmt.getOPAQUE(2));
      System.out.println("Output from ERP :" + reqOutXML.getStringVal());
      output = jaxbUnmarshalFromString(reqOutXML.getStringVal());

This gave me “java.lang.ClassCastException: com.sun.gjc.spi.jdbc40.ConnectionHolder40 cannot
be cast to oracle.jdbc.OracleConnection” Exception. The connection was being returned from GlassFish JDBC ConnectionPool and was instance of OracleConnectionPooldataSource.
The FIX proved tricky, but in the end it was simple –
Do this –

OracleConnection oraCon = con.unwrap(OracleConnection.class);
//The IN parameter for stored proc is Oracle XDB XMLType
atpInXml = XMLType.createXML(oraCon, atpInStr);

Pass the cast instance of OracleConnection to the XMLType API.

Connect to GlassFishMQ / OpenMQ from ActiveMQ using Camel configuration


, , , , ,

I was working on a solution based on ActiveMQ where we required to pull messages from GlassFishMQ (based on OpenMQ) and put them on OracleAQ.

Now, ActiveMQ uses Camel ESB for internal message routing, this proved useful. However try as I might, I couldn’t find a simple solution to what I wanted to achieve.

My target was to configure ActiveMQ broker which’ll act as a message router and decouple the 2 systems. Both would be unaware of its presence. Sounds really good in theory providing loose coupling.

But the difficult part was finding documentation. All the documentation available was about using ActiveMQ as JMS provider in GlassFish. Not what I was looking at.

So finally after much difficulty, I found the solution. It is simple but difficult to find.

Step 1) Copy imq.jar to ActiveMQ lib directory. The jar is found in GLASSFISH_HOME/imq/lib

Step 2) Add below lines to your activemq configuration file –

This line creates a default connectionFactory using host localhost and port 7676

<bean id="connectionFactoryOpenMQQueue"/>


This part creates a bean with credentials

<bean id="openMQQueueCredentials">
<property name="targetConnectionFactory">
<ref bean="connectionFactoryOpenMQQueue"/>
<property name="username">
<property name="password">

This part created the actual scheme, namespace identifier for the connection.

<bean id="openMQQueue">
<property name="connectionFactory" ref="openMQQueueCredentials"/>

Step 3) Add the routing instructions

This’ll consume message from GlassFishMQ and put it on ActiveMQ’s queue. You can check the messages at http://localhost:8161/admin

<from uri="openMQQueue:queue:q_user_info" />
<to  uri="activemq:queue:amq.temp.userinfo.queue"/>

Referred to this info on how to configure the ConnectionFactory –

Database Diff / Database Change Management



Recently we had a situation when two developers were working on same DB package. Delay in submission of deployment request by one dev resulted in package compilation error as a dependent Type was missing.
I was looking for solution that may help us avoid such situations in future.

Using SVN is one option; other is use of Database Change Management / Database Diff
Some tools for that are –

1) Oracle Change Management Pack
From the docs –
There are three core capabilities of Change Management that allow developers and database administrators to manage changes in database environments:
• Baseline – A point in time of the definition of the database and its associated database objects.
• Comparison – A complete list of differences between a baseline or a database and another baseline or a database.
• Synchronization – The process of promoting changes from a database definition capture in a baseline or from a database to a target database

It allows us to take a baseline(snapshot) at a fixed time and then later we can see how the DB schema and objects have changed. The CMP can also generate DDL scripts, though I am not sure we would want to use it.


2) PL/SQL Developer Compare User Objects feature
This is available from Tools -> Compare User Objects

3) Oracle SQL Developer Database Diff feature
This is available from Tools -> Database diff See “Schema Copy and Compare”

#1 looks to be most versatile and flexible but DBA rights may be necessary.
#2 & 3 can be used by any developer. I think Oracle SQL Developer is easier and provides more options.

Using any of the above option can help in –
1) Identifying the changed objects and may also serve as a Check List before requesting deployment.

2) The developers concerned can take ownership of specific changed objects.