Author |
Message
|
dharvesh79 |
Posted: Tue Dec 06, 2016 12:55 am Post subject: Dynamic Validation IN IIB |
|
|
Newbie
Joined: 06 Dec 2016 Posts: 5
|
Hi All,
Is it possible to validate any message dynamically in IIB. The Message model name or XSD name will be fetched from DB and it needs to be validated.
I know we can use validate node, but is there any possibility of setting the Message model name dynamically there.
One more possibility is using WSRR and i dont want to use WSRR now.
Please suggest me how to do it. |
|
Back to top |
|
 |
adubya |
Posted: Tue Dec 06, 2016 1:15 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
|
Back to top |
|
 |
timber |
Posted: Tue Dec 06, 2016 3:07 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
You can use CREATE...PARSE to dynamically select the message model name. But the schemas must already be deployed - you cannot dynamically *deploy* a schema to IIB.
In general, it's not a great idea to 'deploy' your XSDs to a database instead of to IIB. It gets far too easy to make uncontrolled changes. |
|
Back to top |
|
 |
dharvesh79 |
Posted: Tue Dec 06, 2016 10:57 pm Post subject: |
|
|
Newbie
Joined: 06 Dec 2016 Posts: 5
|
timber wrote: |
You can use CREATE...PARSE to dynamically select the message model name. But the schemas must already be deployed - you cannot dynamically *deploy* a schema to IIB.
In general, it's not a great idea to 'deploy' your XSDs to a database instead of to IIB. It gets far too easy to make uncontrolled changes. |
Is it possible for you to provide me an example of that create...parse statement.
Also i am not deploying the XSD in DB. The XSD is in IIB but the name alone dynamically fetched from DB. |
|
Back to top |
|
 |
adubya |
Posted: Tue Dec 06, 2016 11:27 pm Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
dharvesh79 wrote: |
timber wrote: |
You can use CREATE...PARSE to dynamically select the message model name. But the schemas must already be deployed - you cannot dynamically *deploy* a schema to IIB.
In general, it's not a great idea to 'deploy' your XSDs to a database instead of to IIB. It gets far too easy to make uncontrolled changes. |
Is it possible for you to provide me an example of that create...parse statement.
. |
I'll leave that as an exercise for the reader. The Infocentre gives examples, experiment, see how you get on and if you have problems then add them to this thread. Best way to learn  _________________ Independent Middleware Consultant
andy@knownentity.com |
|
Back to top |
|
 |
dharvesh79 |
Posted: Wed Dec 07, 2016 1:00 am Post subject: |
|
|
Newbie
Joined: 06 Dec 2016 Posts: 5
|
adubya wrote: |
dharvesh79 wrote: |
timber wrote: |
You can use CREATE...PARSE to dynamically select the message model name. But the schemas must already be deployed - you cannot dynamically *deploy* a schema to IIB.
In general, it's not a great idea to 'deploy' your XSDs to a database instead of to IIB. It gets far too easy to make uncontrolled changes. |
Is it possible for you to provide me an example of that create...parse statement.
. |
I'll leave that as an exercise for the reader. The Infocentre gives examples, experiment, see how you get on and if you have problems then add them to this thread. Best way to learn  |
I tried using the Create statement.
Code: |
DECLARE options INTEGER BITOR(FolderBitStream, ValidateContentAndValue,
ValidateContentAndValue);
DECLARE inCCSID INT InputProperties.CodedCharSetId;
DECLARE inEncoding INT InputProperties.Encoding;
DECLARE inBitStream BLOB ASBITSTREAM(InputRoot.XMLNSC, inEncoding, inCCSID);
CREATE LASTCHILD OF Environment.Msg.NewData DOMAIN('XMLNSC')
PARSE(inBitStream, inEncoding, inCCSID, 'ValdationMSET',
'Employee', 'XMLNSC', options); |
It created a XML under Environment.Msg.NewData but having header and no body. It says CHARACTER:XML Parsing Errors have occurred.
Now i need to check if there are any error in the xml like the above situation. Please suggest me how to proceed. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Dec 07, 2016 4:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
dharvesh79 wrote: |
It created a XML under Environment.Msg.NewData but having header and no body. It says CHARACTER:XML Parsing Errors have occurred. |
The message wasn't a proper XML document.
dharvesh79 wrote: |
Now i need to check if there are any error in the xml like the above situation. Please suggest me how to proceed. |
In order to find out if the XML message is valid, you have to either a) parse it, b) write your own parser.
Don't write your own parser.
Figure out what it *means* when the message is bad - is it your flow? is it the sender? Do you need to retry it? Do you need to return an error? Do you need to log something? Move the message somewhere? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
timber |
Posted: Wed Dec 07, 2016 6:01 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
It created a XML under Environment.Msg.NewData but having header and no body. |
The debugger displays the message tree at the point where the error occurred. If the debugger is not connected, the message flow never sees that partially-constructed message tree. The exception is thrown and control passes back up the line to the nearest Catch node/node with a Catch terminal wired up.
Quote: |
Now i need to check if there are any error in the xml like the above situation |
mqjeff is correct; either your XML is incorrect or you specified the wrong CCSID. But I think you are describing the next task on your list. What exactly does the requirement say? Can you just return true for 'document is valid' and false otherwise? Who is going to read the error reports emitted by your message flow? |
|
Back to top |
|
 |
dharvesh79 |
Posted: Wed Dec 07, 2016 11:36 pm Post subject: |
|
|
Newbie
Joined: 06 Dec 2016 Posts: 5
|
timber wrote: |
Quote: |
It created a XML under Environment.Msg.NewData but having header and no body. |
The debugger displays the message tree at the point where the error occurred. If the debugger is not connected, the message flow never sees that partially-constructed message tree. The exception is thrown and control passes back up the line to the nearest Catch node/node with a Catch terminal wired up.
Quote: |
Now i need to check if there are any error in the xml like the above situation |
mqjeff is correct; either your XML is incorrect or you specified the wrong CCSID. But I think you are describing the next task on your list. What exactly does the requirement say? Can you just return true for 'document is valid' and false otherwise? Who is going to read the error reports emitted by your message flow? |
Yes you are correct. I have done the create statement to parse it and have an invalid XML. Now i need to either true or false.
IIB flows will read the error that are emitted by this flow. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Dec 08, 2016 5:06 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you need to execute some business logic when a message fails to parse, then you need to expect an exception and catch that exception and then handle it according to the business logic. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|