« August 2007 | Main | November 2007 »

September 2007 Archives

September 21, 2007

RMI Clients receiving faults from BPEL Processes

A few days back, I was struggling with running the RMI Client against the  CreditRatingService with a fault scenario. [setting ssn=0].


I was receiving an UnmarshallException whose root cause was an "InvalidClassException" referring to the class javax.xml.namespace.QName.


On further analysis, I discovered that JDK 1.5 ships with a javax.xml.namespace.QName that carries a different serialVersionUID than the one that ships with JDK 1.4.


Since I was using JDK 1.5_06 to run my RMI Client, it kept on complaining.

Why doesnt my XPath work with unprefixed path elements?

Assume that you had an XML Document like the one illustrated below.






  1.   
  2. <purchaseOrder xmlns="www.oracle.com/po">  
  3.   <id>100</id>  
  4.   <items>  
  5.    <item name="TV">  
  6.      <description>television</description>  
  7.    </item>  
  8.    <item name=VCR">  
  9.      <description>Video Cassette Recorder</description>  
  10.    </item>  
  11.    <item name="DVD">  
  12.      <description>Digital Video Disc</description>  
  13.    </item>  
  14.   </items>  
  15.   <comment>PO from Ramkumar Menon</comment>  
  16. </purchaseOrder>  
You had a piece of java code in which you wish to get the comments from the purchaseOrder. You choose to use the "selectNodes()" API to get the value.




  1.   
  2.   
  3. DOMParser parser = new DOMParser();   
  4. StringReader reader = new StringReader(poXMLString);   
  5. parser.parse(reader);;   
  6. XMLDocument doc = parser.getDocument();   
  7. XMLElement docElement = (XMLElement)doc.getDocumentElement();   
  8. NodeList list = doc.selectNodes("/purchaseOrder/comment",docElement);   
  9. System.err.println("number of items in the list = " + list.getLength());  
Result - Guess what! It is zero. Why ? Here you go! The Location path expression that I just modeled contains a set of location steps "purchaseOrder"and "comment". Xpath expects each of the node names within the location steps to be a QName. [consisting of a namespace URI and a local name]

But, yes, but, if the namespace prefix on the node name is specified to be "empty", the nodes are assumed to come from null namespace, and not the default namespace.

That is exactly why you get zero nodes on the evaluation of the expression.

Whats the workaround?



  1. Ensure that the path elements have a namespace prefix, or
  2. You could use wildcard expressions . For instance,the above expression could be re-written as "/*[local-name()='purchaseOrder'][namespace-uri()='www.oracle.com/po'] /*[local-name()='comments'[namespace-uri()='www.oracle.com/po'] You could use either of these approaches, and you've got what you wished for!

September 28, 2007

Getting the Fault Payload returned by BPEL Processes in RMI Clients

Assume that you have a BPEL Process that returns a Fault may it be business or runtime.


Your RMI Client can receive the payload of the faults from the BPEL Processes by using the snippet below.






  1.   
  2. import oracle.xml.parser.v2.XMLElement;   
  3. import com.oracle.bpel.client.ServerException;   
  4. import com.oracle.bpel.client.BPELFault;   
  5. try {   
  6.   
  7.     //invoke the BPEL process using the DeliveryService API.   
  8.   
  9. }catch(ServerException ex) {   
  10.   
  11.   Throwable t = ex.getCause();   
  12.   
  13.   
  14.   if(t instanceof BPELFault)  {   
  15.   
  16.     BPELFault fault = (BPELFault)t;   
  17.     //in the line below, "payload" is the name of the message part.   
  18.     //replace it with the part name that you have defined in the WSDL.   
  19.     //if its a runtime fault, refer to RuntimeFault.wsdl to obtain the   
  20.     //part name. In that case, the payload will be a string value.   
  21.   
  22.   
  23.     XMLElement faultPayload = (XMLElement)fault.getPart("payload");   
  24.   
  25.   
  26.     //do processing with payload   
  27.   
  28.   }   
  29.   
  30.   
  31. }  

About September 2007

This page contains all entries posted to Ramkumar Menon's Blog in September 2007. They are listed from oldest to newest.

August 2007 is the previous archive.

November 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle