Author |
Message
|
shrusonu |
Posted: Thu Nov 16, 2017 1:50 am Post subject: JCN MbElement to Element |
|
|
 Novice
Joined: 20 Dec 2013 Posts: 16
|
Hello All,
I am working on IIB v10.0.0.9 on windows
I have a problem while calling Java methods from ESQL or JCN java.
I have an existing Java project which contains many classes & methods. I know that we can make a call to java methods from ESQL.
Problem is Existing Java methods have arguments defined of type org.w3c.dom.Element.
How i can achieve if i am using JCN to make calls to these methods? Casting from MbElement to org.w3c.dom.Element is not working throws CAST Exception.
Any links to materials would be helpful.
Your help is very much appreciated.
Thanks |
|
Back to top |
|
 |
timber |
Posted: Thu Nov 16, 2017 9:08 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
I have an existing Java project which contains many classes & methods. |
What do these classes/methods do? If they are manipulating a DOM tree then there may be a better solution. |
|
Back to top |
|
 |
shrusonu |
Posted: Thu Nov 16, 2017 11:01 pm Post subject: |
|
|
 Novice
Joined: 20 Dec 2013 Posts: 16
|
Quote: |
What do these classes/methods do? If they are manipulating a DOM tree then there may be a better solution. |
Yes, the methods do manipulations with DOM Document, NodeList & Element.
I believe the methods would produce a resultant new XML depending upon the input arguments. |
|
Back to top |
|
 |
timber |
Posted: Fri Nov 17, 2017 4:02 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
IIB provides 4 different ways of manipulating the content of XML documents. Why do you want to use these Java classes to do it? Is the transformation logic particularly complex?
If you are determined to pursue this design, you might get more success by using the JAXB option in the JavaCompute node. That presents a message tree as a DOM in the JavaCompute node. But I have no idea whether the JCN DOM objects will be compatible with your legacy Java code. |
|
Back to top |
|
 |
shrusonu |
Posted: Fri Apr 03, 2020 5:20 am Post subject: |
|
|
 Novice
Joined: 20 Dec 2013 Posts: 16
|
Managed to get through it.
here, it might help someone in need -
Code: |
org.w3c.dom.Document doc = com.ibm.broker.plugin.MbMessageAssembly contact admin.getMessage().getDOMDocument();
org.w3c.dom.NodeList nodeList = (NodeList) javax.xml.xpath.evaluate("Give your xPath", doc, XPathConstants.NODESET);
org.w3c.dom.Element element = (Element) nodeList .item(0);
|
Dom element is now passed to legacy code further  |
|
Back to top |
|
 |
|