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 Index » WebSphere Message Broker (ACE) Support » Dynamic validation of XML message using ESQL

Post new topic  Reply to topic
 Dynamic validation of XML message using ESQL « View previous topic :: View next topic » 
Author Message
kaaviraaj
PostPosted: Wed May 14, 2014 5:59 am    Post subject: Dynamic validation of XML message using ESQL Reply with quote

Newbie

Joined: 04 Mar 2014
Posts: 4

Hi All,

I have a requirement where my input message contains the schema and the payload.

I need to validate the payload against the schema on the fly.
Is there any way we can achieve this in MB7 using ESQL.

I am on WMB 7.0.0.6.

I read we can use ASBITSTREAM function to validate the message, but it needs the message set.

Let me know if anyone achieved this in any way.

Thanks in advance.

Vijay
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 14, 2014 6:34 am    Post subject: Re: Dynamic validation of XML message using ESQL Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kaaviraaj wrote:
I need to validate the payload against the schema on the fly.


Why? What in your requirement prevents getting WMB to do it and in what why is WMB's validation not "on the fly" in your context?

kaaviraaj wrote:
I read we can use ASBITSTREAM function to validate the message, but it needs the message set.


Given that the message set is simply a schema, how would you validate any XML without one? On the fly or otherwise?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kaaviraaj
PostPosted: Wed May 14, 2014 6:51 am    Post subject: Dynamic validation of XML message using ESQL Reply with quote

Newbie

Joined: 04 Mar 2014
Posts: 4

Ok.
Let me put it in this way.

I have an input message like this.
<Mymessage>
<Schema1> ....</Schema1>
<Data1> .....</Data1>
<Mymessage>

And I receive another message like
<Mymessage>
<Schema2> ....</Schema2>
<Data2> .....</Data2>
<Mymessage>

and so on..

I am developing a single message flow, which has to read all of these messages and validate the Data against the Schema.

In a way source is defining the schema and the payload in the same message.

Hope it clarifies.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 14, 2014 7:04 am    Post subject: Re: Dynamic validation of XML message using ESQL Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kaaviraaj wrote:
In a way source is defining the schema and the payload in the same message.


Ok, that's anti-pattern. It's like a self signed SSL; how can it not match? Also how can you code or use the data in the schema? Say the application consuming the XML requires a given tag and is content that the tag will be present because the schema (as supplied in the top of the XML) says it's mandatory. The next instance of the same XML has an embedded schema with the tag described as "minOccurs=0" - what's the application supposed to do? The XML's "valid" but can't be processed. An XML schema is a contract between provider and consumer; you can't "renegociate" the contract on an instance by instance basis!

Secondly, is it valid XML for schema elements to appear in an XML document?

Thirdly, what value does this construct have? The reasons you use a schema to validate XML is to determine if the XML is valid and to determine data types within the message. How would you achieve these objective with this construct?

What's the actual business requirement to do this, as opposed to the "I've been told to do this" requirement?

IMHO an XML document constructed like this is not valid XML and well formed on a technicality. The only way you're going to do what you propose to do is build your own custom XML parser, and WMB is not the ideal tool to do this. You'd be better off in C++ or Java and have a stand-alone application.

IF you actually want to do this crazy thing.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed May 14, 2014 12:44 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I agree with Vitor. I would be very interested to know what the *business* requirement is.

FWIW, XML Schema is 'just XML' so there is no technical problem with embedding an XSD in an XML document. In fact, inlined WSDL does it all the time. But that does not mean that it is a good idea to do what the OP is asking for.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
kaaviraaj
PostPosted: Thu May 15, 2014 4:43 am    Post subject: Dynamic validation of XML message using ESQL Reply with quote

Newbie

Joined: 04 Mar 2014
Posts: 4

Thanks for the replies.

I understood the implications.

The current requirement is, we will be receiving business data from different applications, in a different format.

Rite now they are having the schema as part of the payload.

I am trying to see, whether we can achieve these requirement in WMB using ESQL.

As you suggested this is not a proper way of handling the validations. I must restrain myself from using this approach. .

But I have a question, in what scenarios we use validation using ASBITSTREAM function as mentioned in the Infocenter?.

Thanks again.

Vijay
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu May 15, 2014 4:49 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I have a question, in what scenarios we use validation using ASBITSTREAM function as mentioned in the Infocenter
I hear you asking 'if ASBITSTREAM is not intended for my xsd-embedded-in-xml scenario, then what *is* it for?'.

There are many cases where the application developer wants to take control of how and when the various parts of a document get serialized. If you search this forum you will find various examples. It certainly was not intended for the requirement that you asked about, in case there is any remaining doubt
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu May 15, 2014 5:37 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

I have to wonder if this proposed message structure is a way to get around the concept of a 'contract' like you have with WSDL's.

By including the schema in with the message, the sender can say,

Here you go, here is the data. We may have changed the structure but you should be able to sort it out because we have given you the schema.

Thus it is putting the whole load of sorting out their [redacted] message on your shoulders.
I don't like it, and if I were on the receiving end of this, I'd be raising a stink.

IMHO, this is not best practice, no way, no how, not ever.
I consider it totally unmaintainable.
_________________
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
View user's profile Send private message
Vitor
PostPosted: Fri May 16, 2014 4:36 am    Post subject: Re: Dynamic validation of XML message using ESQL Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kaaviraaj wrote:
The current requirement is, we will be receiving business data from different applications, in a different format.


Which is a good reason to have external schemas separate from the payload, for the reasons my most worthy associate lays out.

kaaviraaj wrote:
I am trying to see, whether we can achieve these requirement in WMB using ESQL.


Probably. I doubt that it's the best or easiest tool to achieve this very silly requirement.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamic validation of XML message using ESQL
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.