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 » Parse Xml in CDATA

Post new topic  Reply to topic
 Parse Xml in CDATA « View previous topic :: View next topic » 
Author Message
rabee_nawash
PostPosted: Fri Feb 05, 2016 11:20 pm    Post subject: Parse Xml in CDATA Reply with quote

Apprentice

Joined: 01 Dec 2014
Posts: 27

I have an xml text passed through SOAP message using CDATA , I want to validate it against xsd file and if succeeded fill the data in the XSD object, is there any way to do that in IBM integration bus, and is their a visual way of doing it?
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Feb 05, 2016 11:43 pm    Post subject: Reply with quote

Jedi Council

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

There are a number of Threads in the Message Broker Forum here that discuss CDATA and parsing there of. The comments by Timber/Kimbert are expecially relevant to your question.

Please take some time to look at these threads. The Google search box on the upper right on this page will help you.
_________________
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
rabee_nawash
PostPosted: Sat Feb 06, 2016 9:09 am    Post subject: Reply with quote

Apprentice

Joined: 01 Dec 2014
Posts: 27

smdavies99 wrote:
There are a number of Threads in the Message Broker Forum here that discuss CDATA and parsing there of. The comments by Timber/Kimbert are expecially relevant to your question.

Please take some time to look at these threads. The Google search box on the upper right on this page will help you.



Thank you Timber, but none of them helped me. My issue not with parsing alone its parsing with validation. I was able to parse the xml message but regardless of if its valid against its schema. Meaning I changed submit a message with tags which its not exists in the XSD file but again it pass the parsing and it parse the validate node. My issue is that I need to check if the data passed in the CDATA is correct before rout it to another web service.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Sat Feb 06, 2016 10:33 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.

how are you doing the parsing?
How are you validating it?

The product can certainly validate a message tree against an XSD schema and if it fails, it will throw an error.

This is SOP for many of us. So, what are you doing exactly? Examples/sample code will help us here.
_________________
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
rabee_nawash
PostPosted: Sat Feb 06, 2016 10:55 am    Post subject: Reply with quote

Apprentice

Joined: 01 Dec 2014
Posts: 27

Request SOAP Message : Note the XML is inside transactionData CDATA

Code:
<?xml version="1.0" encoding="UTF-8"?><tns0:Envelope xmlns:tns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns1="http://www.xyzhealth.com/b2b/health/po/schema/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <tns0:Header/>
  <tns0:Body>
    <tns1:ProcessTransaction>
      <transactionId>transactionId</transactionId>
      <transactionType>transactionType</transactionType>
      <transactionData>
       <data<![CDATA[<?xml version="1.0" encoding="utf-8"?>
   <Prior.Request
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="https://www.health.com/DataDictionary/CommonTypes/PriorRequest.xsd">
      <Header>
         <SenderID>MF23</SenderID>
         <ReceiverID>A001</ReceiverID>
         <TransactionDate>11/05/2014 10:57</TransactionDate>
         <RecordCount>1</RecordCount>
         <DispositionFlag>PTE_VALIDATE_ONLY</DispositionFlag>
      </Header>   
      <Authorization>
         <Type>Authorization</Type>
         <ID>SIL_Aug6_2014</ID>
         <IDPayer>10992273</IDPayer>
         <MemberID>695076</MemberID>
         <PayerID>A001</PayerID>
         <EmiratesIDNumber>784-1984-3761860-0</EmiratesIDNumber>
         <DateOrdered>11/05/2014</DateOrdered>
         <Encounter>
            <FacilityID>MF23</FacilityID>
            <Type>1</Type>            
         </Encounter>
         <Diagnosis>
            <Type>Principal</Type>
            <Code>540.0</Code>
         </Diagnosis>
      </Authorization>
   </Prior.Request>]]></data>
      </transactionData>
      <transactionAttachments/>
      <callExtensions>
        <extension/>
      </callExtensions>
    </tns1:ProcessTransaction>
  </tns0:Body>
</tns0:Envelope>




smdavies99 wrote:
how are you doing the parsing?
How are you validating it?

I parse the XML like this
Code:
SET OutputLocalEnvironment.Variables.data = FIELDVALUE(InputRoot.XMLNSC.ns:ProcessTransaction.transactionData.(XMLNSC.CDataField));
         SET OutputRoot = InputRoot;
      CREATE LASTCHILD OF OutputLocalEnvironment.Variables.XMLMessage DOMAIN ('XMLNSC') PARSE (OutputLocalEnvironment.Variables.data CCSID 1208);


The product can certainly validate a message tree against an XSD schema and if it fails, it will throw an error.

I use the validate node to validate, but I don't know how to assign the XSD schema to it? there is no option for that, please note the XSD is available to the application thruough its library

This is SOP for many of us. So, what are you doing exactly? Examples/sample code will help us here.
Code:
Code:
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Feb 06, 2016 7:55 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

I doubt very much that the validate node was built to validate what is in the Environment or local environment tree.
You have essentially 2 possibilities.
  • Change the code to make validation happen on your CREATE PARSE command and deal with the error handling...
  • use a FLOW ORDER node to split the flow. On the first branch move the parsed XML to OutputRoot.XMLNSC and put it to the VALIDATE node. On the error terminal of the VALIDATE node attach a THROW node.
    This will prevent the second branch to be executed if the CData does not validate...


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rabee_nawash
PostPosted: Sun Feb 07, 2016 4:06 am    Post subject: Reply with quote

Apprentice

Joined: 01 Dec 2014
Posts: 27

Thank you fjb_saper,

I used the second approach (Flow Order), but still I the xml pass the validation however it shouldn't .. My question how IIB will know to which XSD schema the validation should run..

Currently this is my situation

The message tree after using the Flow Order and moved the new parsed xml into the XMLNSC

Code:


Message
   XMLNSC
         Prior.Request
               xsi:CHARACTER:http://www.w3.org/2001/XMLSchema-instancenoNamespaceSchemaLocation:CHARACTER:https://www.health.com/DataDictionary/CommonTypes/PriorRequest.xsd
               Header
                     SenderID:CHARACTER:MF23
                     ReceiverID:CHARACTER:A001
                     TransactionDate:CHARACTER:11/05/2014 10:57
                     RecordCount:CHARACTER:1
                     DispositionFlag:CHARACTER:PTE_VALIDATE_ONLY
               :CHARACTER:Authorization1
                     ID1:CHARACTER:SIL_Aug6_2014
                     IDPayer:CHARACTER:10992273
                     MemberID2:CHARACTER:695076
                     PayerID:CHARACTER:A001
                     EmiratesIDNumber:CHARACTER:784-1984-3761860-0
                     DateOrdered:CHARACTER:11/05/2014
                     Encounter
                           FacilityID:CHARACTER:MF23
                           Type:CHARACTER:1Authorization

                                    Type
                     Diagnosis
                           Type:CHARACTER:Principal
                           Code:CHARACTER:540.0
                     Activity
                           ID:CHARACTER:1
                           Start:CHARACTER:10/04/2012 11:00
                           Type:CHARACTER:5
                           Code:CHARACTER:1288-1472-001
                           Quantity:CHARACTER:1.0
                           Net:CHARACTER:500.0
                           Clinician:CHARACTER:GN6489
                           Observation
                                 Type:CHARACTER:Text
                                 Code:CHARACTER:Dose
                                 Value:CHARACTER:25
                                 ValueType:CHARACTER:Mg



and the XSD schema in a file called PriorRequest.xsd
Code:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) --><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" id="PriorRequest" version="2.0" xmlns:tns="http://www.health.com/DataDictionary/CommonTypes" xmlns:xsd="undefined">
  <xs:import namespace="http://www.health.com/DataDictionary/CommonTypes" schemaLocation="CommonTypes.xsd"/>
  <xs:element name="Prior.Request">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Header">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="SenderID" type="tns:HeaderSenderID"/>
              <xs:element name="ReceiverID" type="tns:HeaderReceiverID"/>
              <xs:element name="TransactionDate" type="tns:HeaderTransactionDate"/>
              <xs:element name="RecordCount" type="tns:HeaderRecordCount"/>
              <xs:element name="DispositionFlag" type="tns:HeaderDispositionFlag"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Authorization">
           <xs:complexType>
              <xs:sequence>
                 <xs:element name="Type" type="tns:AuthorizationType"/>
                 <xs:element name="ID" type="tns:AuthorizationID"/>
                 <xs:element minOccurs="0" name="IDPayer" type="tns:AuthorizationIDPayer"/>
                 <xs:element name="MemberID" type="tns:AuthorizationMemberID"/>
                 <xs:element name="PayerID" type="tns:AuthorizationPayerID"/>
                 <xs:element minOccurs="0" name="EmiratesIDNumber" type="tns:AuthorizationEmiratesIDNumber"/>
                 <xs:element minOccurs="0" name="DateOrdered" type="tns:AuthorizationDateOrdered"/>
                 <xs:element minOccurs="0" name="Encounter">
                    <xs:complexType>
                       <xs:sequence>
                          <xs:element name="FacilityID" type="tns:EncounterFacilityID"/>
                          <xs:element minOccurs="0" name="Type" type="tns:EncounterType"/>
                     <xs:element minOccurs="0" name="Start" type="tns:EncounterStart"/>
                     <xs:element minOccurs="0" name="End" type="tns:EncounterEnd"/>
                       </xs:sequence>
                    </xs:complexType>
                 </xs:element>
               <xs:element maxOccurs="unbounded" minOccurs="0" name="Diagnosis">
                  <xs:complexType>
                     <xs:sequence>
                        <xs:element name="Type" type="tns:DiagnosisType"/>
                        <xs:element name="Code" type="tns:DiagnosisCode"/>
                        <xs:element maxOccurs="unbounded" minOccurs="0" name="DxInfo">
                           <xs:complexType>
                              <xs:sequence>
                                 <xs:element name="Type" type="tns:DxInfoType"/>
                                 <xs:element name="Code" type="tns:DxInfoCode"/>
                              </xs:sequence>
                           </xs:complexType>
                        </xs:element>
                     </xs:sequence>
                  </xs:complexType>
               </xs:element>
               <xs:element maxOccurs="unbounded" minOccurs="0" name="Activity">
                  <xs:complexType>
                     <xs:sequence>
                        <xs:element name="ID" type="tns:ActivityID"/>
                        <xs:element minOccurs="0" name="Start" type="tns:ActivityStart"/>
                        <xs:element name="Type" type="tns:ActivityType"/>
                        <xs:element name="Code" type="tns:ActivityCode"/>
                        <xs:element minOccurs="0" name="Quantity" type="tns:ActivityQuantity"/>
                        <xs:element name="Net" type="tns:ActivityNet"/>
                        <xs:element minOccurs="0" name="OrderingClinician" type="tns:ActivityOrderingClinician"/>
                        <xs:element minOccurs="0" name="Clinician" type="tns:ActivityClinician"/>
                        <xs:element maxOccurs="unbounded" minOccurs="0" name="Observation">
                           <xs:complexType>
                              <xs:sequence>
                                 <xs:element name="Type" type="tns:ObservationType"/>
                                 <xs:element name="Code" type="tns:ObservationCode"/>
                                 <xs:element minOccurs="0" name="Value" type="tns:ObservationValue"/>
                                 <xs:element minOccurs="0" name="ValueType" type="tns:ObservationValueType"/>
                              </xs:sequence>
                           </xs:complexType>
                        </xs:element>
                     </xs:sequence>
                  </xs:complexType>
               </xs:element>
                 <xs:element minOccurs="0" name="Resubmission">
                    <xs:complexType>
                       <xs:sequence>
                     <xs:element minOccurs="0" name="Type" type="tns:ResubmissionType"/>
                     <xs:element name="Comment" type="tns:ResubmissionComment"/>
                     <xs:element minOccurs="0" name="Attachment" type="tns:ResubmissionAttachments"/>
                       </xs:sequence>
                    </xs:complexType>
                 </xs:element>
              </xs:sequence>
           </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


See here authorization1 is not valid authorization type as per the schema , how the mapping will happen or there is something wrong with the name spaces
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Feb 07, 2016 8:33 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

You did deploy the xsd as a message model right?
Look at your schema, and then look at your message: where are the namespaces shown in the schema? Looks like the message is missing them....
You also might want to show what your xsd looks like after import into the toolkit and validation...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
timber
PostPosted: Sun Feb 07, 2016 1:38 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

This thread should answer your questions:
http://www.mqseries.net/phpBB2/viewtopic.php?t=49318&postdays=0&postorder=asc&start=15

The submitter is using the MRM parser ( for no particularly good reason ) but the principles are the same. You *must* include an OPTIONS clause in your CREATE...PARSE statement; otherwise no validation will happen.
Back to top
View user's profile Send private message
rabee_nawash
PostPosted: Sun Feb 07, 2016 3:44 pm    Post subject: Reply with quote

Apprentice

Joined: 01 Dec 2014
Posts: 27

On the first branch move the parsed XML to OutputRoot.XMLNSC and put it to the VALIDATE node. On the error terminal of the VALIDATE node attach a THROW node.
This will prevent the second branch to be executed if the CData does not validate...[/list]

The issue I think that the parse removed the xmlnd and nsi attributes that's why when it reach the parse node the node can't locate the xsd file. Any idea how I can return back the xmlns and nsi to the nonamespaceschemalocation

Have fun [/quote]
Back to top
View user's profile Send private message
timber
PostPosted: Mon Feb 08, 2016 1:50 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
The issue I think that the parse removed the xmlnd and nsi attributes
I don't understand; XMLNSC does not throw away information when it parses an XML document. Please check your spelling, and explain more clearly what you mean.
Quote:
...that's why when it reach the parse node the node can't locate the xsd file.
IIB does not need to 'locate the xsd'. It uses the model that was deployed with the application. I assume that you have deployed your xsd(s)?

Have you tried using the OPTIONS clause in the CREATE...PARSE statement yet?
Back to top
View user's profile Send private message
rabee_nawash
PostPosted: Mon Feb 08, 2016 1:09 pm    Post subject: Reply with quote

Apprentice

Joined: 01 Dec 2014
Posts: 27

timber wrote:
Quote:
The issue I think that the parse removed the xmlnd and nsi attributes
I don't understand; XMLNSC does not throw away information when it parses an XML document. Please check your spelling, and explain more clearly what you mean.
Quote:
...that's why when it reach the parse node the node can't locate the xsd file.
IIB does not need to 'locate the xsd'. It uses the model that was deployed with the application. I assume that you have deployed your xsd(s)?

Have you tried using the OPTIONS clause in the CREATE...PARSE statement yet?


This is the XML String before parsing

Code:
data:CHARACTER:<?xml version="1.0" encoding="utf-8"?>
   <Prior.Request
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="PriorRequest.xsd"]>
      <Header>
         <SenderID>MF23</SenderID>
         <ReceiverID>A001</ReceiverID>
         <TransactionDate>11/05/2014 10:57</TransactionDate>
         <RecordCount>1</RecordCount>
         <DispositionFlag>PTE_VALIDATE_ONLY</DispositionFlag>
      </Header>   
      <Authorization>
         <Type>Authorization</Type>
         <ID>SIL_Aug6_2014</ID>
         <IDPayer>10992273</IDPayer>
         <MemberID>695076</MemberID>
         <PayerID>A001</PayerID>
                    ...........


and this is after parsing

Code:
XMLMessage
   XMLNSC
         XmlDeclaration
               Version:CHARACTER:1.0
               Encoding:CHARACTER:utf-8
         Prior.Request
               xsi:CHARACTER:http://www.w3.org/2001/XMLSchema-instance
               noNamespaceSchemaLocation:CHARACTER:PriorRequest.xsd
               Header
                     SenderID:CHARACTER:MF23
                     ReceiverID:CHARACTER:A001
                     TransactionDate:CHARACTER:11/05/2014 10:57
                     RecordCount:CHARACTER:1
                     DispositionFlag:CHARACTER:PTE_VALIDATE_ONLY
               Authorization
                     Type:CHARACTER:Authorization
                     ID:CHARACTER:SIL_Aug6_2014
                     IDPayer:CHARACTER:10992273
                     MemberID:CHARACTER:695076
                     PayerID:CHARACTER:A001


Yes thanks its working with options, but I still prefer to use the validate node, any idea why the parse change the attributes prefix

Code:

Prior.Request
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="PriorRequest.xsd"]>


Thanks any way my problem is resolved
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Feb 08, 2016 1:22 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

rabee_nawash wrote:

Yes thanks its working with options, but I still prefer to use the validate node, any idea why the parse change the attributes prefix

Can you please be more specific?
My guess is because in the environment tree you don't have a default parser and you have to explicitely set it for attributes to behave correctly...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Feb 08, 2016 1:23 pm    Post subject: Reply with quote

Grand High Poobah

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

rabee_nawash wrote:
any idea why the parse change the attributes prefix


The prefix of any namespace is irrelevant. The only question is which namespace a given XML element is in, either through specific allocation or one of the defaulting mechanisms. The only thing the prefix (the left hand side of the colon) does is save you typing.

I don't see where the parsed version differs from the original on that basis.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Feb 08, 2016 1:52 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
I don't see where the parsed version differs from the original



_________________
chmod -R ugo-wx /
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 » Parse Xml in CDATA
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.