Author |
Message
|
lrasalas01 |
Posted: Fri Jul 25, 2008 12:14 am Post subject: Problem reading XML attribute from Inputmessage. |
|
|
Novice
Joined: 16 Jul 2008 Posts: 14
|
Hello everybody,
I am reading XML into a fixed length text message.
I am having problem reading XML attribute values from input message in XML domain. I have tried following thing but nothing happens; not even an error.(Output message is generated without attribute values).
Code: |
SET OutputRoot.MRM.ListOfAction.Action.MessageID = InputRoot.XML.SMessage.(XML.Attribute)MessageId; |
My XML message is in following format.
Code: |
<SMessage MessageId="00000001">
<ListOfAction>
<Action>
<QmgrName>TSTENV01</QmgrName>
...
</Action>
</ListOfAction>
</SMessage>
|
I could convert normal element values (like QmgrName) to fixed length string without problem.
Thanks,
LR |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jul 25, 2008 12:23 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Hi,
Have you looked / searched from user trace how broker parses the incoming message? I have found that while developing it is a very good habit to echo incoming message before mapping and outgoing message after and see if I can find hints from there what can be wrong.
Marko |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jul 25, 2008 12:36 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Hi lrasalas01,
- Please stop using the XML domain. It is deprecated. Use XMLNSC for all new message flows.
- Put a Trace node after your input node and set the Pattern property to '${Root}'. Take a user trace ( debug level ), and you will see the message tree ( and lot of other useful info ) in the user trace.
If you don't know how to take a user trace, look up mqsichangetrace, mqsireadlog, mqsiformatlog in the docs. |
|
Back to top |
|
 |
lrasalas01 |
Posted: Fri Jul 25, 2008 2:32 am Post subject: |
|
|
Novice
Joined: 16 Jul 2008 Posts: 14
|
Marko, Kimbert,
I took the trace and found that message is being generated as follows.
Code: |
{HEADER DATA UPTO HERE}(0x01000021):MRM = ( (0x0300000D):@MessageId = 'xxx' (0x01000013):ListOfAction = ( (0x01000013):Action = ( (0x0300000B):QmgrName = ....... |
kimbert, I am sorry, let me correct myself. I am actually using MRM domain with input message format of XML. So I have to use this statement to access child elements of Action tag and it works fine.
Code: |
InputRoot.MRM.ListOfAction.Action.QmgrName |
Now the problem is I can't refer to attribute like InputRoot.MRM.attributeName
Is there any other way to achive this?
By the way, I am working on older versions.
OS: Solaris 5.9
Message Broker Toolkit: 5.0.3
WebSphere MQ 530.7 CSD07 |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jul 25, 2008 3:08 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
LR,
I have seen this before --somehow-- with MRM broker parses xml attributes with @ -prefix.
So you have to refer to it like SET OutputRoot.MRM.ListOfAction.Action.MessageID = InputRoot.MRM.SMessage.@MessageId;
Marko |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jul 25, 2008 3:13 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
And to be precise --no SMessage root tag reference needed.
SET OutputRoot.MRM.ListOfAction.Action.MessageID = InputRoot.MRM.@MessageId;
Marko |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jul 25, 2008 3:31 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I have seen this before --somehow-- with MRM broker parses xml attributes with @ -prefix. So you have to refer to it like SET OutputRoot.MRM.ListOfAction.Action.MessageID = InputRoot.MRM.SMessage.@MessageId; |
Please ignore that piece of advice.
If the MRM parser puts an '@' prefix on an attribute, it means that the attribute was self-defining ( it was not found in the message definition). That is a serious problem which should be fixed.
Obviously, this is not an issue in v6.1 - nobody would want to use MRM XML in v6.1, would they? |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jul 25, 2008 3:51 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Thanks Kimbert for the correction. Now we/I know the reason for the @ -prefixes ;.)
Marko |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Jul 25, 2008 4:49 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Hi all,
I searched a little and it is still allowed(?) to use self-defined elements with MRM / XML physical format, but as Kimbert denoted it is perhaps better to correct the message model to contain all attributes & elements?
Marko
Quote: |
WebSphere Message Broker 6.1 Information Center
MRM XML physical format
.
.
.
XML messages are, by their nature, self-describing: each piece of data is prefixed by a tag name or an attribute name. Therefore, it is possible for an XML message instance to contain elements which are not in the definition for that message.
* If such an element exists in the message set, the model objects for that element are used in parsing or writing the message.
* If the element does not exist in the message set, it is treated as a self-defining element and its data type is set to string.
|
|
|
Back to top |
|
 |
kimbert |
Posted: Fri Jul 25, 2008 5:03 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Hi marko,
Yes, if your attributes are self-defining by design then that's OK. But you just told lrasalas01 to add an '@' to his ESQL path. You didn't say anything about checking whether the attribute should be self-defining.
Any advice which you or I provide on this thread might be read and acted upon by other people. That's why I posted that reply. |
|
Back to top |
|
 |
lrasalas01 |
Posted: Mon Jul 28, 2008 3:19 am Post subject: |
|
|
Novice
Joined: 16 Jul 2008 Posts: 14
|
Hi Kimbert,
As per you said, there was a difference of definition between input message and output message set. I had a hunch about that. Should have looked in that direction at the first place.
I redefined both the message sets (since there were other differences too like lengths of fixed-length-string fields etc) and now it works perfectly.
I can access the attributes of a root element just by InputRoot.MRM.attribteName
Quote: |
Obviously, this is not an issue in v6.1 - nobody would want to use MRM XML in v6.1, would they? |
You are absolutely right, if I had an option I wouldn't use MRM. But right now I am stuck with the maintenance of this old message flow. No choice!
Thanks for the replies,
LR |
|
Back to top |
|
 |
|