Author |
Message
|
mqlover |
Posted: Fri Jan 04, 2013 12:42 am Post subject: Reading the XML msg |
|
|
Disciple
Joined: 25 Jul 2010 Posts: 176
|
Hi,
I have a requirement where in I will have to read one field from the XML msg and use it my ESQL for further computation.
If I use the XMLNSC parser then it I am getting the error i.e "XML Parsing Errors have occurred" and getting an Exception saying that the namespaces need to be declared.
The msg sender end have not declared any Namespaces so they have no idea reg teh declaration of namespaces.
Could anyone help me out how to read the msg as the msg contains Namespaces and there are different namespaces for different msgs.
Ex : cr - credit, dd - direct debit etc.
Thanks in advance |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jan 04, 2013 12:52 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Hi,
What version of broker you are using?
--
Marko
Last edited by marko.pitkanen on Fri Jan 04, 2013 12:53 am; edited 1 time in total |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Jan 04, 2013 12:52 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
What version & patch level of broker are you using?
Is the XML valid?
Can you give us an example of the incoming message?
What is the FULL ERROR TEXT shown in a UserTrace output? There are several lines of data. We really need to see it all.
Quote: |
The msg sender end have not declared any Namespaces so they have no idea reg teh declaration of namespaces.
Could anyone help me out how to read the msg as the msg contains Namespaces and there are different namespaces for different msgs.
|
I am a bit confused here. firstly you say that they have not declared any namespaces then you say 'read as the msg contains Namespaces'.
Which of those statements is true? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqlover |
Posted: Fri Jan 04, 2013 1:15 am Post subject: Reading the XML msg |
|
|
Disciple
Joined: 25 Jul 2010 Posts: 176
|
This is the sample xml msg.
I am trying to read the value in bp:OrgnlInstrId but am getting the errors saying "XML Parsing Errors have occurred".
<BankStatementResponse>
<bp:BankStmtResp>
<bp:StmtResp>
<bp:OrgnlInstrId>20110311BKBBSGSGBAD0000010</bp:OrgnlInstrId>
</bp:StmtResp>
</bp:BankStmtResp>
</BankStatementResponse>
Broker version is 7.0.0.3.
I have not declared any namespaces. I am getting the error "bp" namespace not declared.
I am not allowed to use trace nodes, hence cannot provide the trace output. |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jan 04, 2013 1:25 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
What is your ESQL statement you are using to access the OrgnlInstrId -element?
--
Marko |
|
Back to top |
|
 |
mqlover |
Posted: Fri Jan 04, 2013 1:41 am Post subject: Reading the XML msg |
|
|
Disciple
Joined: 25 Jul 2010 Posts: 176
|
SET Environment.Variables.UUID = InputRoot.XMLNSC.BankStatementResponse.bp:BankStmtResp.bp:StmtResp.bp:OrgnlInstrId; |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jan 04, 2013 1:44 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Hi,
With closer look to your data, it seems that it is not possible to parse with namespace aware parser, because namespace prefix bp: is not defined in the data.
You have two options:
1) Ask message sender to declare prefix in the data or
2) use deprecated XML domain which do not care about undefined namespace prefixes.
I think that the option 1) is the preferred way to solve this problem.
--
Marko |
|
Back to top |
|
 |
mqlover |
Posted: Fri Jan 04, 2013 1:50 am Post subject: Reading the XML msg |
|
|
Disciple
Joined: 25 Jul 2010 Posts: 176
|
I tried both the options :
1 . The user refused to give the namespace declaration.
2 . I tried to Use XML deprecated parser. There were no errors but the below field was not populated.
SET Environment.Variables.UUID = InputRoot.XML.BankStatementResponse.bp:BankStmtResp.bp:StmtResp.bp:OrgnlInstrId;
Thanks |
|
Back to top |
|
 |
kash3338 |
Posted: Fri Jan 04, 2013 1:51 am Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
Can you try this,
Code: |
SET Environment.Variables.UUID = InputRoot.XMLNSC.BankStatementResponse.*:BankStmtResp.*:StmtResp.*:OrgnlInstrId;
|
|
|
Back to top |
|
 |
mqlover |
Posted: Fri Jan 04, 2013 2:25 am Post subject: Reading the XML msg |
|
|
Disciple
Joined: 25 Jul 2010 Posts: 176
|
Nope, am getting the same error again!! |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jan 04, 2013 2:27 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
This problem is nothing to do with message broker - it is caused by the user sending badly-formed XML. Any XML parser, from any vendor, will report an error for that XML. If you don't believe me, try viewing the XML file using a browser and see what happens.
Quote: |
The user refused to give the namespace declaration. |
Did they just refuse, or did they give you a reason why it cannot be done? |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jan 04, 2013 3:02 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Hi,
If you really need to take option 2) you have to refer to element with following format
Code: |
InputRoot.XML.BankStatementResponse."bp:BankStmtResp"."bp:StmtResp"."bp:OrgnlInstrId"; |
Quote: |
Because the names used must be valid ESQL identifiers, you can use only names that conform to the rules of ESQL. That is, the names can contain only alphanumeric characters including underscore, the first character cannot be numeric, and names must be at least one character long. You can avoid these limitations by enclosing names not conforming to these rules in double quotation marks. For example:
InputRoot.XMLNS."Customer Data".Invoice |
--
Marko |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jan 04, 2013 3:25 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
kash3338 said:
Quote: |
Can you try this,
Code: |
SET Environment.Variables.UUID = InputRoot.XMLNSC.BankStatementResponse.*:BankStmtResp.*:StmtResp.*:OrgnlInstrId; |
|
That would help if there was a message tree containing namespaces. The problem is that the incoming XML is badly-formed, so it cannot be parsed. No message tree is available. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jan 04, 2013 3:25 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
kash3338 said:
Quote: |
Can you try this,
Code: |
SET Environment.Variables.UUID = InputRoot.XMLNSC.BankStatementResponse.*:BankStmtResp.*:StmtResp.*:OrgnlInstrId; |
|
That would help if there was a message tree containing namespaces. The problem is that the incoming XML is badly-formed, so it cannot be parsed. No message tree is available. |
|
Back to top |
|
 |
mqsiuser |
Posted: Fri Jan 04, 2013 3:47 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
XML is a strict standard: The sender must remove the prefixes "ns1:..." or add the namespace declarations "xmlns:ns1=..."
It would be totally against this idea if you'd take their msg in (using the BLOB-domain), fix (their) issues and then use a reset content descriptor to set to XMLNSC. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
|