Author |
Message
|
satya2481 |
Posted: Tue May 08, 2012 9:55 pm Post subject: MRM XML Validation with PARSE Statement Not validating |
|
|
Disciple
Joined: 26 Apr 2007 Posts: 170 Location: Bengaluru
|
Hi All,
I am using WMB V6.1.0.8 and trying to parse request message against MRM XML Message definition. The ESQL Code looks like below.
Code: |
DECLARE parserOptions INTEGER BITOR(ValidateContentAndValue, ValidateException);
CREATE LASTCHILD OF ClientData.ParsedMsg AS ParsedMsg DOMAIN ('MRM')
PARSE(BLOBMsg
OPTIONS parserOptions
SET 'MessageSetId'
TYPE 'MsgType'
FORMAT 'XML'
ENCODING InputRoot.MQMD.Encoding
CCSID InputRoot.MQMD.CodedCharSetId); |
Message definition is having around 100 fields.
Suppose a new field (Which is not present in the Message definition) is sent in the request message I am expecting above statement to rhrow an error indicating new field is present in the Request message other than the fields defined in the message set. But there are no errors and no Exceptions.
Is this the expected behaviour ? If not how to achieve the requirement of throwing an error if new field is sent in the request message ?
Thank You
Regards
Satya |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue May 08, 2012 11:10 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
So what happens when you try it with the extra field?
Have you looked at the OPTIONS available for the CREATE PARSE?
ValidateContentAndValue might just do the job. _________________ 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 |
|
 |
kimbert |
Posted: Tue May 08, 2012 11:17 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You should not be using the MRM parser to parser and/or validate an XML document. Why are you not using XMLNSC?
ValidateImmediate is the option that you need - otherwise the parser will be given the bit stream but will not actually do any parsing until you access one of the child elements of 'ParsedMsg'. |
|
Back to top |
|
 |
satya2481 |
Posted: Wed May 09, 2012 6:04 am Post subject: |
|
|
Disciple
Joined: 26 Apr 2007 Posts: 170 Location: Bengaluru
|
Quote: |
Why are you not using XMLNSC? |
The code and the message set are existing projects. Requirement is not to use any other domain. Hence using MRM XML as it is.
I have not yet tried ValidateImmediate option. |
|
Back to top |
|
 |
kimbert |
Posted: Wed May 09, 2012 6:17 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
OK - that's a valid reason for using MRM XML. But please don't use it in new message flows. |
|
Back to top |
|
 |
satya2481 |
Posted: Mon May 14, 2012 12:04 am Post subject: |
|
|
Disciple
Joined: 26 Apr 2007 Posts: 170 Location: Bengaluru
|
Anyone see any other option to validate the complete message ?
Or any issues with my approach? |
|
Back to top |
|
 |
kimbert |
Posted: Mon May 14, 2012 12:21 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Did you try with ValidateImmediate? You don't need to use XMLNSC - ValidateImmediate applies to MRM as well. |
|
Back to top |
|
 |
satya2481 |
Posted: Wed May 16, 2012 2:51 am Post subject: |
|
|
Disciple
Joined: 26 Apr 2007 Posts: 170 Location: Bengaluru
|
Yes, I have tried with below parserOptions.
Code: |
DECLARE parserOptions INTEGER BITOR(ValidateContentAndValue, ValidateException, ValidateImmediate)
DECLARE parserOptions INTEGER BITOR(ValidateContentAndValue, ValidateException, ValidateComplete) |
In both cases the PARSE statement not throwing any error. It simply passes the values as it is.
I do not want to use Sequence option. Because the fields can come in any order. I just want to validate such a way that if any new field is sent in the input XML Message the PARSE statement has to throw an error indicating <FieldName> is not present in the definition. |
|
Back to top |
|
 |
kimbert |
Posted: Wed May 16, 2012 3:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Your next step is to prove that your input XML document does not match the xsd. You can do that in various ways:
- Try it with XMLNSC. If XMLNSC does not throw a validation error then the document is valid, with 99.9% confidence.
- create an XML project in the broker toolkit and import your xsd and XML document
- use a third-party XML editing tool such as XMLSpy
If all else fails, cut down your XSD and XML to the minimum size, and post them here. |
|
Back to top |
|
 |
satya2481 |
Posted: Wed May 16, 2012 9:34 pm Post subject: |
|
|
Disciple
Joined: 26 Apr 2007 Posts: 170 Location: Bengaluru
|
MRM XML Message set is created manually and not from the schema. Schema is not available. However I have created the schema from the message definition and validated the request message in XML Spy and its validating correctly. I mean error is reported if a new field is added in the request message. |
|
Back to top |
|
 |
kimbert |
Posted: Thu May 17, 2012 12:44 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please post your xsd and example message(s). |
|
Back to top |
|
 |
deepnair |
Posted: Thu May 17, 2012 6:58 am Post subject: |
|
|
Apprentice
Joined: 07 Feb 2012 Posts: 35
|
Another way is to check if your coming message is XML (convert BLOB to string and check for XML), if yes then only for validation purpose - parse it as XMLNSC and throw error.
If there is no exception, then convert the blob to MRM and continue your processing.
Thanks,
Deep Nair |
|
Back to top |
|
 |
kimbert |
Posted: Thu May 17, 2012 11:55 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
@deepnair: Sounds as if the same effect could be achieved by setting the domain on the input node to 'XMLNSC' and then using an RCD node immediately after the input node.
btw, I don't think the OP has any doubts about whether the data is XML. |
|
Back to top |
|
 |
deepnair |
Posted: Thu May 17, 2012 12:48 pm Post subject: |
|
|
Apprentice
Joined: 07 Feb 2012 Posts: 35
|
@Kimbert - Yes you are right, they can do at the input node but I think @satya is planning to reuse an exisitng message set and an exisitng flow that caters to non XML too, so they cannot modify the input node to XMLNSC but handle the XML in compute node via Parser options.
Either way - XMLNSC will be a better fit here...  |
|
Back to top |
|
 |
satya2481 |
Posted: Thu May 17, 2012 9:15 pm Post subject: |
|
|
Disciple
Joined: 26 Apr 2007 Posts: 170 Location: Bengaluru
|
Thank you all for your responses.
However I didnt get any response where I can try out few options.
As I earlier told the code is existing code, we are having a framework for parser. So I can not alter the input node domain. I cant add RCD node either. My requirement is to use PARSE statement and use MRM XML Domain only and validate the message.
As of now I am just adding PARSE statment and proceeding. Though it will not validate the incoming message completely. |
|
Back to top |
|
 |
|