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 IndexWebSphere Message Broker SupportGenerate XML message from XSD schema inside messageflow

Post new topicReply to topic
Generate XML message from XSD schema inside messageflow View previous topic :: View next topic
Author Message
KoGor
PostPosted: Fri Jul 28, 2017 12:40 am Post subject: Generate XML message from XSD schema inside messageflow Reply with quote

Voyager

Joined: 09 Nov 2005
Posts: 77
Location: Moscow,Russia.

Hi all!
I have to create a messageflow that receive a simple BLOB 'trigger' message. After such BOLB message recieved I should create a total new XML message (with no data from trigger message) and put it to queue. I have an XSD schema for this new XML message. I've already imported XSD schema into message definition, so I've *.mxsd in message flow. But I cann't find a simple way to create an empty XML message from this message defifnition inside message flow. Is there a way to do it?
Now, I can see only the option how to create this XML - it's create an empty XML structure from scratch inside COMPUTE node using CRETE FIELD (and etc.) and then populate it with data. But I don't belive that it's the right way to do it.
Thank you in advance!
Back to top
View user's profile Send private message
timber
PostPosted: Fri Jul 28, 2017 3:12 am Post subject: Reply with quote

Yatiri

Joined: 25 Aug 2015
Posts: 643

Why are you using a message set (.mxsd)? There is no good reason for creating new message sets these days. Just import the XSDs into the library/application. ( and I hope you are using XMLNSC and not MRM for the parsing and writing of XML).

Regardless of that...the IIB runtime does not contain any features to generate XML messages from an XSD. The IIB toolkit can generate example XML documents from an XML schema, but usually it's not very useful.

Maybe it would help if you explain why you want to do this?
Back to top
View user's profile Send private message
KoGor
PostPosted: Fri Jul 28, 2017 3:56 am Post subject: Reply with quote

Voyager

Joined: 09 Nov 2005
Posts: 77
Location: Moscow,Russia.

Yes, I'm using XMLNSC not MRM for outgoing message. I've imported XSD into message set because I've tried to find an easy way to create an XML message from COMPUTE node. Now it seems that there is no other way to create outgoing XML except to define and set all its elements directly from ESQL. I.e. something like this:

Code:
        CREATE LASTCHILD OF OUTROOT DOMAIN 'XMLNSC' NAMESPACE soapenv NAME 'Envelope';
        SET OUTROOT.soapenv:Envelope.(XMLNSC.NamespaceDecl)xmlns:soapenv=soapenv;
        SET OUTROOT.soapenv:Envelope.(XMLNSC.NamespaceDecl)xmlns:soapenc=soapenc;
        SET OUTROOT.soapenv:Envelope.(XMLNSC.NamespaceDecl)xmlns:sds = sds;
        SET OUTROOT.soapenv:Envelope.(XMLNSC.NamespaceDecl)xmlns:props=props;
         SET OUTROOT.soapenv:Envelope.soapenv:Header.props:From = FromHostName;
          SET OUTROOT.soapenv:Envelope.soapenv:Header.props:To = ToHostName;
        SET OUTROOT.soapenv:Envelope.soapenv:Header.props:Priority = Priority;   
       CREATE LASTCHILD OF OUTROOT.soapenv:Envelope NAMESPACE soapenv NAME 'Body'; .... and etc...
Back to top
View user's profile Send private message
joebuckeye
PostPosted: Fri Jul 28, 2017 4:25 am Post subject: Reply with quote

Partisan

Joined: 24 Aug 2007
Posts: 305
Location: Columbus, OH

I would strongly suggest the use of references to simplify your code, make future updates easier and improve readability.
Code:
        CREATE LASTCHILD OF OUTROOT DOMAIN 'XMLNSC' NAMESPACE soapenv NAME 'Envelope';
        DECLARE refWorking REFERENCE TO OutputRoot.soapenv:Envelope;
        SET refWorking.(XMLNSC.NamespaceDecl)xmlns:soapenv=soapenv;
        SET refWorking.(XMLNSC.NamespaceDecl)xmlns:soapenc=soapenc;
        SET refWorking.(XMLNSC.NamespaceDecl)xmlns:sds = sds;
        SET refWorking.(XMLNSC.NamespaceDecl)xmlns:props=props;
        SET refWorking.soapenv:Header.props:From = FromHostName;
        MOVE refWorking TO refWorking.soapenv:Header;
        SET refWorking.props:To = ToHostName;
        SET refWorking.props:Priority = Priority;   
        CREATE LASTCHILD OF OUTROOT.soapenv:Envelope NAMESPACE soapenv NAME 'Body';
        MOVE refWorking TO refWorking.soapenv:Body;
        ...etc


Instead of constantly moving one reference you could create an Envelope reference, a Header reference, a Body reference, etc. Whatever works for you.
Back to top
View user's profile Send private message
timber
PostPosted: Fri Jul 28, 2017 4:46 am Post subject: Reply with quote

Yatiri

Joined: 25 Aug 2015
Posts: 643

If you are not mapping the contents of the XML from an input, why not just hard-code the XML document as a CHARACTER constant, CAST it to a BLOB (specifying the CCSID very carefully, of course) and send it to the destination using the BLOB domain.
Back to top
View user's profile Send private message
KoGor
PostPosted: Fri Jul 28, 2017 5:05 am Post subject: Reply with quote

Voyager

Joined: 09 Nov 2005
Posts: 77
Location: Moscow,Russia.

timber wrote:
If you are not mapping the contents of the XML from an input, why not just hard-code the XML document as a CHARACTER constant, CAST it to a BLOB (specifying the CCSID very carefully, of course) and send it to the destination using the BLOB domain.


I have to populate some fields with time and data. But this's a good point! I can hard-code some lond parts of XML message and then just to clue them. Thank you!

Quote:
I would strongly suggest the use of references to simplify your code, make future updates easier and improve readability.

Yes, I usually use references to address elements. This code is just for example. Thanks for this hint anyway, it may be usefull for others!
Back to top
View user's profile Send private message
timber
PostPosted: Fri Jul 28, 2017 6:47 am Post subject: Reply with quote

Yatiri

Joined: 25 Aug 2015
Posts: 643

Right - so you're not really generating a random message. You're taking a boilerplate message and changing a couple of fields.

In that case
- Declare the boilerplate XML message as a CHARACTER
- Create a message tree from it using CREATE...PARSE
- SET the appropriate fields to override their value
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportGenerate XML message from XSD schema inside messageflow
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.