ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportsetIdAttribute function throwing error in Java compute node

Post new topicReply to topic
setIdAttribute function throwing error in Java compute node View previous topic :: View next topic
Author Message
shubham_rajput
PostPosted: Wed Nov 29, 2017 9:42 pm Post subject: setIdAttribute function throwing error in Java compute node Reply with quote

Newbie

Joined: 29 Aug 2017
Posts: 5

Hi,
I am using File input node to send my XML file in Java compute node.
Here is the XML file that I am sending via File input node:
Code:

<?xml version="1.0" encoding="UTF-8"?>
<ebicsNoPubKeyDigestsRequest
 xmlns="urn:org:ebics:H004"
 xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="urn:org:ebics:H004 ebics_keymgmt_request_H004.xsd"
 Version="H004" Revision="1">
    <header authenticate="true">
        <static>
            <HostID>EBIXHOST</HostID>
            <Nonce>234AB2340FD2C23035764578FF3091FA</Nonce>
            <Timestamp>2005-01-30T15:40:45.123Z</Timestamp>
            <PartnerID>CUSTM001</PartnerID>
            <UserID>USR100</UserID>
            <OrderDetails>
                <OrderType>HPB</OrderType>
                <OrderAttribute>DZHNN</OrderAttribute>
            </OrderDetails>
            <SecurityMedium>0000</SecurityMedium>
        </static>
        <mutable/>
    </header>
    <AuthSignature>
    </AuthSignature>     
    <body/>
</ebicsNoPubKeyDigestsRequest>


I have set the Message domain property in File input node as XMLNSC. Using Java compute node I am trying to form the signature of those elements in XML whose attribute "authenticate="true"".
Here is my Java compute node code inside evaluate function.

Code:

// create new message as a copy of the input
         MbMessage outMessage = new MbMessage(inMessage);
         outAssembly = new MbMessageAssembly(contact admin, outMessage);
Document doc = outMessage.getDOMDocument();
KeyPair loadedKeyPair = getKeyPairFromKeyStore();

         // Retrieving both Public and Private key from the loaded key pairs
         PrivateKey privateKey = loadedKeyPair.getPrivate();
          // Instance main XML Signature Toolkit.
         XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
           XPathFactory xPathfactory = XPathFactory.newInstance();
          
           // Retreive Assertion Node to be signed.
           XPath xpath = xPathfactory.newXPath();
           XPathExpression exprAssertion = xpath.compile("//*[local-name()='ebicsNoPubKeyDigestsRequest']//*[local-name()='header']");
           Element assertionNode = (Element) exprAssertion.evaluate(doc, XPathConstants.NODE);
// Must mark ID Atrribute as XML ID to avoid BUG in Java 1.7.25.
           try
           {
              assertionNode.setIdAttribute("authenticate", true);
           }
           catch(DOMException e){
              System.err.println("Caught Exception: " + e.getMessage());
              throw e;
           }


In above code inside the try block when I am trying to set the "authenticate" attribute as ID via setIDAttribute it throws an error
Code:

org.w3c.dom.DOMException: ID attribute not supported


But If I replace the code
Code:

 Document doc = outMessage.getDOMDocument();


with the code to retrieve the XML directly from my local system than it shows no error:
Code:

File fXmlFile = new File("D:/in.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);


Is it a problem with Document doc = outMessage.getDOMDocument();
that the above line of code converts the XML file in some other form.[/code]
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 30, 2017 5:47 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24648
Location: Ohio, USA

Ok, now my Java is not the strongest, so explain to me how you're parsing the document with the XMLNSC parser and expecting a DOM object you can navigate rather than an IIB message tree.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Nov 30, 2017 6:08 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19432
Location: LI,NY

Quote:
// Must mark ID Atrribute as XML ID to avoid BUG in Java 1.7.25.

Is this comment for IBM Java or Oracle Java ?
You do know that when you run IIB you run it on top of the corresponding IBM Java ...
What is the result in the DOM Document when you set this outside of the broker? Try and use the same element / attribute (visual not reusing java code) and then code for that in the broker...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportsetIdAttribute function throwing error in Java compute node
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.