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 » Trouble with parsing CDATA from xml message

Post new topic  Reply to topic
 Trouble with parsing CDATA from xml message « View previous topic :: View next topic » 
Author Message
dziku007
PostPosted: Mon Dec 08, 2014 12:40 pm    Post subject: Trouble with parsing CDATA from xml message Reply with quote

Apprentice

Joined: 26 Jul 2012
Posts: 32

hello,

I'm using Message Broker 8.0.0.4. I have input message like this
Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://xyz">
   <soap:Header/>
   <soap:Body>
      <ns:SearchDataResponse>
         <ns:SearchDataResult><![CDATA[<innerMsg><a></a></innerMsg>]]></ns:SearchDataResult>
      </ns:SearchDataResponse>
   </soap:Body>
</soap:Envelope>


I want to store xml from CDATA in Environment.Variables (as a tree). I'm doing this:
Code:

DECLARE xmlString CHARACTER InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult;
CREATE LASTCHILD OF Environment.Variables.msg DOMAIN 'XMLNSC' PARSE  (xmlString, InputProperties.Encoding, InputProperties.CodedCharSetId);


Unfortunately I'm getting
Code:
XML Parsing Errors have occurred
value in Environment.Variables.msg.

UserTrace says me:
Code:
Executing statement   ''DECLARE xmlString CHARACTER InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult;'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '15.3').
2014-12-08 21:15:28.862940      556   UserTrace   BIP2539I: Node '': Evaluating expression ''InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '15.31'). This resolved to ''InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult''. The result was '''<![CDATA[<innerMsg><a></a></innerMsg>]]>'''.
2014-12-08 21:15:30.104924      556   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''CREATE LASTCHILD OF Environment.Variables.XMLMessage0 DOMAIN 'XMLNSC' PARSE(xmlString, InputProperties.Encoding, InputProperties.CodedCharSetId);'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '47.4').
2014-12-08 21:15:31.470720      556   UserTrace   BIP2539I: Node '': Evaluating expression ''xmlString'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '47.82'). This resolved to ''xmlString''. The result was '''<![CDATA[<innerMsg><a></a></innerMsg>]]>'''.
2014-12-08 21:15:31.470828      556   UserTrace   BIP2539I: Node '': Evaluating expression ''InputProperties.Encoding'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '47.93'). This resolved to ''InputProperties.Encoding''. The result was ''546''.
2014-12-08 21:15:31.470864      556   UserTrace   BIP2539I: Node '': Evaluating expression ''InputProperties.CodedCharSetId'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '47.119'). This resolved to ''InputProperties.CodedCharSetId''. The result was ''1208''.
2014-12-08 21:15:31.471062      556   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''DECLARE i INTEGER 1;'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '54.4').
2014-12-08 21:15:31.569860      556   UserTrace   BIP5004E: An XML parsing error ''The markup in the document preceding the root element must be well-formed.'' occurred on line 1 column 3 when parsing element ''/Root/Variables/XMLMessage0/XMLNSC''. 
                                       Internal error codes are '1511' and '2'.
                                       This error was reported by the generic XML parser, and is usually the result of a badly formed XML message.
                                       Check that the input XML message is a well-formed XML message that adheres to the XML specification. The line number and column number that are quoted in the message give the position where the parser discovered the problem. However, the actual error might be earlier in the message. 
                                       Other possible causes are: 
                                       1. A character that is not supported by XML occurs in the instance message data. 
                                            XML supports only a subset of control characters; therefore, ensure that no unsupported characters, such as X'00', appear in the document. 
                                       2. The Coded Character Set ID that is defined in the message header does not reflect the contents of the instance message. 
                                            If the XML document has an XML prologue, the WebSphere MQ CodedCharSetId should be consistent with the XML Encoding field. 
                                       3. A reserved XML character appears in the instance message data. 
                                            Characters that might be recognized as XML markup - for example, < and & - should be replaced with the corresponding XML entities - &lt; and &amp;


So it seems that parser does not understand CDATA prefix and suffix string, and treats it as a wrong xml.

I've red a lot of threads in this forum, generally the solutions I met are concentrating on CREATE ... PARSE ... DOMAIN operation, for example:
http://www.mqseries.net/phpBB2/viewtopic.php?t=34834
http://www.mqseries.net/phpBB/viewtopic.php?p=295687&sid=5f8d9930f4fec2a7c6352219ce27a0e9

I tried to read more about CDATA in Knowledge Center, but I have only found how to create xml containing CDATA:
http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67174_.htm

Sorry by sending issue that already exists in other threads, but after few hours spending on this I hope that some of You, especially experienced guys, will be able to point me where I am doing a mistake.
Back to top
View user's profile Send private message
Simbu
PostPosted: Tue Dec 09, 2014 12:06 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Hi, Issue here is the way you are accessing the CDATA. Requesting you to read the below post again.
http://www.mqseries.net/phpBB/viewtopic.php?p=295687&sid=5f8d9930f4fec2a7c6352219ce27a0e9

kimbert wrote:
CDATA has two advantages:
a) it leaves the embedded XML human-readable ( because you don't have to replace < with &lt; everywhere ).
b) it protects against most types of badly-formed XML document

The catch, as mqjeff says, is that it only protects against 'most' badly-formed documents. If the embedded XML contains an illegal character then the whole document will be badly-formed. The only way to avoid that is to base64 encode the embedded XML.

If you're sure that CDATA is the right choice for you, then you need to do something like this:
Code:
CREATE LASTCHILD OF OutputRoot.XMLNSC PARSE InputRoot.XMLNSC.(XMLNSC.CDataField)data;


The above code is not tested, but something very similar will work.
Back to top
View user's profile Send private message
dziku007
PostPosted: Tue Dec 09, 2014 2:24 am    Post subject: Reply with quote

Apprentice

Joined: 26 Jul 2012
Posts: 32

Thanks for Your answer Simbu,

I tried doing something similar as You suggested:

Code:

SET Environment.Variables.data = InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult;
CREATE LASTCHILD OF OutputRoot.XMLNSC PARSE (Environment.Variables.(XMLNSC.CDataField)data, InputProperties.Encoding, InputProperties.CodedCharSetId);


After that OutputRoot.XMLNSC is empty. After user trace analysis broker complies the same as in my original post
Code:
Internal error codes are '1511' and '2'.
                                       This error was reported by the generic XML parser, and is usually the result of a badly formed XML message.
Back to top
View user's profile Send private message
Simbu
PostPosted: Tue Dec 09, 2014 3:16 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Hi dziku007,

you should also take care of namespace. the right way is

Code:
InputRoot.SOAP.Body.*:SearchDataResponse.(XMLNSC.CDataField)*:SearchDataResult;
Back to top
View user's profile Send private message
dziku007
PostPosted: Tue Dec 09, 2014 4:30 am    Post subject: Reply with quote

Apprentice

Joined: 26 Jul 2012
Posts: 32

Simbu: Appreciating and following Your suggestion i tried:

Code:

SET Environment.Variables.data = InputRoot.SOAP.Body.nsx:SearchDataResponse.(XMLNSC.CDataField)nsx:SearchDataResult;
CREATE LASTCHILD OF OutputRoot.XMLNSC PARSE (Environment.Variables.(XMLNSC.CDataField)data, InputProperties.Encoding, InputProperties.CodedCharSetId);


But still without solution.
Now SET instruction ends with a null value in Environment.Variables.data.

user trace:
Code:
2014-12-09 13:06:52.425564     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''SET Environment.Variables.data = InputRoot.SOAP.Body.nsx:SearchDataResponse.(XMLNSC.CDataField)nsx:SearchDataResult;'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '56.4').
2014-12-09 13:06:54.350276     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''XMLNSC.CDataField'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '56.81'). This resolved to ''XMLNSC.CDataField''. The result was ''50331649''.
2014-12-09 13:06:54.350472     9664   UserTrace   BIP2543I: Node '': ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '56.37') : Failed to navigate to path element number '5' because it does not exist.
2014-12-09 13:06:54.350528     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''XMLNSC.CDataField'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '56.81'). This resolved to ''XMLNSC.CDataField''. The result was ''50331649''.
2014-12-09 13:06:54.350572     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputRoot.SOAP.Body.nsx:SearchDataResponse.(XMLNSC.CDataField)nsx:SearchDataResult'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '56.37'). This resolved to ''InputRoot.SOAP.Body.http://xyz:SearchDataResponse.(50331649)http://xyz:SearchDataResult''. The result was ''EMPTY ROW''.
2014-12-09 13:06:54.350616     9664   UserTrace   BIP2567I: Node 'MyService.Compute': Assigning NULL to ''Environment.Variables.data'', thus deleting it.
2014-12-09 13:06:54.350672     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''CREATE LASTCHILD OF OutputRoot.XMLNSC PARSE(Environment.Variables.(XMLNSC.CDataField)data, InputProperties.Encoding, InputProperties.CodedCharSetId);'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '57.4').
2014-12-09 13:08:09.387134     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''XMLNSC.CDataField'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '57.72'). This resolved to ''XMLNSC.CDataField''. The result was ''50331649''.
2014-12-09 13:08:09.387219     9664   UserTrace   BIP2543I: Node '': ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '57.49') : Failed to navigate to path element number '3' because it does not exist.
2014-12-09 13:08:09.387262     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''XMLNSC.CDataField'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '57.72'). This resolved to ''XMLNSC.CDataField''. The result was ''50331649''.
2014-12-09 13:08:09.387292     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''Environment.Variables.(XMLNSC.CDataField)data'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '57.49'). This resolved to ''Environment.Variables.(50331649)data''. The result was ''NULL''


Does it proove that InputRoot.SOAP.Body.nsx:SearchDataResponse.nsx:SearchDataResult is not CDataField or does it proove SET operation is just badly constructed? I'm asking because
Code:
SET Environment.Variables.data = InputRoot.SOAP.Body.nsx:SearchDataResponse.nsx:SearchDataResult;

without (XMLNSC.CDataField) assigns <![CDATA[<innerMsg><a></a></innerMsg>]]> to Environment.Variables.data
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Dec 09, 2014 5:13 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

The CREATE...PARSE statement converts a BLOB to a tree using a parser.
In recent versions of WMB/IIB it is possible to use CREATE...PARSE to convert a CHARACTER field to a tree using a parser.
I cannot remember whether 8.0.0.4 includes the second option, but it looks as if it does not.

My guess is that the XMLNSC parser is trying to interpret the CHARACTER field as a BLOB in the same encoding as the input message. That's not correct, so it is failing almost immediately.
I would try this:
- convert the CHARACTER field to a BLOB using a CAST statement. Do not forget to specify a CCSID for the CAST!
- Use the same CCSID with CREATE...PARSE to convert the BLOB to an XMLNSC message tree.
_________________
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
dziku007
PostPosted: Tue Dec 09, 2014 6:24 am    Post subject: Reply with quote

Apprentice

Joined: 26 Jul 2012
Posts: 32

Thanks Kimbert for another suggestion. Following it tried:
Code:

DECLARE myBlob BLOB;
SET myBlob = CAST ( InputRoot.SOAP.Body.nsx:SearchDataResponse.nsx:SearchDataResult AS BLOB CCSID InputProperties.CodedCharSetId ENCODING InputProperties.Encoding);          
CREATE LASTCHILD OF OutputRoot.XMLNSC DOMAIN('XMLNSC') PARSE (myBlob, InputProperties.Encoding, InputProperties.CodedCharSetId);


Now after CREATE broker complains the same thing as in my original post:
Code:
2014-12-09 15:05:17.895240     9664   UserTrace   BIP5004E: An XML parsing error ''The markup in the document preceding the root element must be well-formed.'' occurred on line 1 column 3 when parsing element ''/Root/XMLNSC/XMLNSC''. 
                                       Internal error codes are '1511' and '2'.
                                       This error was reported by the generic XML parser, and is usually the result of a badly formed XML message.
                                       Check that the input XML message is a well-formed XML message that adheres to the XML specification. The line number and column number that are quoted in the message give the position where the parser discovered the problem. However, the actual error might be earlier in the message. 
                                       Other possible causes are: 
                                       1. A character that is not supported by XML occurs in the instance message data. 
                                            XML supports only a subset of control characters; therefore, ensure that no unsupported characters, such as X'00', appear in the document. 
                                       2. The Coded Character Set ID that is defined in the message header does not reflect the contents of the instance message. 
                                            If the XML document has an XML prologue, the WebSphere MQ CodedCharSetId should be consistent with the XML Encoding field. 
                                       3. A reserved XML character appears in the instance message data. 
                                            Characters that might be recognized as XML markup - for example, < and & - should be replaced with the corresponding XML entities - &lt; and &amp;.


What is interesting if i change my test service to return regular xml string:
Code:
<innerMsg><a></a></innerMsg>
instead of CDATA encapsulated string:
Code:
<![CDATA[<innerMsg><a></a></innerMsg>]]>
it works. So parser has trobule with understanding CDATA encapsulation. Does anybody have any idea how to fix it?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Dec 09, 2014 6:39 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Does it change the value you get back if you access the field as a CDATASection directly, rather than as a plain XMLNSC.Field ?
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Dec 09, 2014 7:15 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

There is something very strange going on here. The XMLNSC parser never puts the leading characters '<![CDATA[' or the trailing characters ']]>' into the message tree. Those characters are markup, not data.
But the user trace in your first post clearly shows this:
Code:
2014-12-08 21:15:28.862940      556   UserTrace   BIP2539I: Node '': Evaluating expression ''InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '15.31'). This resolved to ''InputRoot.SOAP.Body.*:SearchDataResponse.*:SearchDataResult''. The result was '''<![CDATA[<innerMsg><a></a></innerMsg>]]>'''.
2014-12-08 21:15:30.104924


Please can you put a Trace node into your message flow. Position it directly after the SOAPInput node and set the Pattern to '${Root}'. If you leave 'Destination' set to 'User Trace' then you will get the output in the user trace along with the other useful info.

If there is any message flow logic between the SOAPInput and the Compute node then please add another Trace node just before the Compute node.

Also, please can you check that the XML and code that you posted is exactly what was used when generating the user trace.
_________________
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
dziku007
PostPosted: Tue Dec 09, 2014 8:11 am    Post subject: Reply with quote

Apprentice

Joined: 26 Jul 2012
Posts: 32

Thanks for Your patience.

mqjeff: Your question is not clear for me. Assuming that You are asking about http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67245_.htm I tried:
Code:
DECLARE str CHAR InputRoot.SOAP.Body.nsx:DaneSzukajResponse.(XML.CDataSection)nsx:DaneSzukajResult;

I'm getting null value in str variable.


kimbert: I'm adding a user trace. User trace is from the return from SOAPRequest node (it is the moment when I got CDATA).
Code:
2014-12-09 16:49:23.262766     9664   UserTrace   BIP4060I: Data ''MyTrace2
                                       ( ['SOAPRoot' : 0x1f23ad00]
                                         (0x01000000:Name  ):Properties         = ( ['SOAPPROPERTYPARSER' : 0x1e4463b0]
                                           (0x03000000:NameValue):MessageSet             = 'My_Service_MessageSet' (CHARACTER)
                                           (0x03000000:NameValue):MessageType            = '' (CHARACTER)
                                           (0x03000000:NameValue):MessageFormat          = '' (CHARACTER)
                                           (0x03000000:NameValue):Encoding               = 546 (INTEGER)
                                           (0x03000000:NameValue):CodedCharSetId         = 1208 (INTEGER)
                                           (0x03000000:NameValue):Transactional          = FALSE (BOOLEAN)
                                           (0x03000000:NameValue):Persistence            = FALSE (BOOLEAN)
                                           (0x03000000:NameValue):CreationTime           = GMTTIMESTAMP '2014-12-09 15:49:06.056' (GMTTIMESTAMP)
                                           (0x03000000:NameValue):ExpirationTime         = -1 (INTEGER)
                                           (0x03000000:NameValue):Priority               = 0 (INTEGER)
                                           (0x03000000:NameValue):ReplyIdentifier        = X'000000000000000000000000000000000000000000000000' (BLOB)
                                           (0x03000000:NameValue):ReplyProtocol          = 'SOAP-AXIS2' (CHARACTER)
                                           (0x03000000:NameValue):Topic                  = NULL
                                           (0x03000000:NameValue):ContentType            = 'application/soap+xml;charset=utf-8' (CHARACTER)
                                           (0x03000000:NameValue):IdentitySourceType     = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentitySourceToken    = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentitySourcePassword = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentitySourceIssuedBy = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentityMappedType     = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentityMappedToken    = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentityMappedPassword = '' (CHARACTER)
                                           (0x03000000:NameValue):IdentityMappedIssuedBy = '' (CHARACTER)
                                         )
                                         (0x01000000:Name  ):HTTPResponseHeader = ( ['WSRSPHDR' : 0x287a7f0]
                                           (0x03000000:NameValue):X-Original-HTTP-Status-Line = 'HTTP/1.1 200 OK' (CHARACTER)
                                           (0x03000000:NameValue):X-Original-HTTP-Status-Code = 200 (INTEGER)
                                           (0x03000000:NameValue):Server                      = 'Apache-Coyote/1.1' (CHARACTER)
                                           (0x03000000:NameValue):Content-Type                = 'application/soap+xml;charset=utf-8' (CHARACTER)
                                           (0x03000000:NameValue):Content-Length              = '300' (CHARACTER)
                                           (0x03000000:NameValue):Date                        = 'Tue, 09 Dec 2014 15:49:06 GMT' (CHARACTER)
                                         )
                                         (0x01000000:Folder):SOAP               = ( ['SOAP' : 0x1071eb60]
                                           (0x01000000:Folder):Context = ( ['xmlnsc' : 0x1788850]
                                             (0x03000100:Attribute  ):operation         = 'SearchData' (CHARACTER)
                                             (0x03000100:Attribute  ):operationType     = 'REQUEST_RESPONSE' (CHARACTER)
                                             (0x03000100:Attribute  ):portType          = 'IMyService' (CHARACTER)
                                             (0x03000100:Attribute  ):portTypeNamespace = 'http://xyz' (CHARACTER)
                                             (0x03000100:Attribute  ):port              = 'e1' (CHARACTER)
                                             (0x03000100:Attribute  ):service           = 'MyService' (CHARACTER)
                                             (0x03000100:Attribute  ):fileName          = 'C:\ProgramData\Application Data\IBM\MQSI\components\MB8BROKER\a0f97df0-4501-0000-0080-815df583c5ad\config\XSD\My_Service_MessageSet/xyz/MyService.wsdl' (CHARACTER)
                                             (0x03000000:PCDataField):SOAP_Version      = '1.2' (CHARACTER)
                                             (0x01000000:Folder     ):Namespace         = (
                                               (0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:NS1 = 'http://www.w3.org/2003/05/soap-envelope' (CHARACTER)
                                             )
                                           )
                                           (0x01000000:Folder):Header  =
                                           (0x01000000:Folder):Body    = ( ['xmlnsc' : 0x1788850]
                                             (0x01000000:Folder)http://xyz:SearchDataResponse = (
                                               (0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:io            = 'http://xyz' (CHARACTER)
                                               (0x03000000:PCDataField  )http://xyz:SearchDataResult = '<![CDATA[<innerMsg><a></a></innerMsg>]]>' (CHARACTER)
                                             )
                                           )
                                         )
                                       )
                                       
                                       
                                       '' from trace node 'MyService.Trace'.
                                       The trace node 'MyService.Trace' has output the specified trace data.
                                       This is an information message provided by the message flow designer.  The user response will be determined by the local environment.
2014-12-09 16:49:23.262914     9664   UserTrace   BIP4067I: Message propagated to output terminal for trace node 'MyService.Trace'.
                                       The trace node 'MyService.Trace' has received a message and is propagating it to any nodes connected to its output terminal.
                                       No user action required.
2014-12-09 16:49:23.263410     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''DECLARE QueueOut SHARED CONSTANT CHARACTER 'XXX';'' at ('.QueueOut', '1.1').
2014-12-09 16:49:23.263566     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';'' at ('.soapenv', '1.1'). 
2014-12-09 16:49:23.263634     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''DECLARE nsx NAMESPACE 'http://xyz';'' at ('MyService_SetCustomDict', '4.1').
2014-12-09 16:49:23.263722     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''BEGIN ... END;'' at ('MyService_SetCustomDict.Main', '2.2').
2014-12-09 16:49:23.263754     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''CopyEntireMessage();'' at ('MyService_SetCustomDict.Main', '5.3').
2014-12-09 16:49:23.263816     9664   UserTrace   BIP2538I: Node 'MyService.Compute': Evaluating expression ''CopyEntireMessage()'' at ('MyService_SetCustomDict.Main', '5.8').
2014-12-09 16:49:23.263856     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''BEGIN ... END;'' at ('MyService_SetCustomDict.CopyEntireMessage', '1.39').
2014-12-09 16:49:23.263886     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''SET OutputRoot = InputRoot;'' at ('MyService_SetCustomDict.CopyEntireMessage', '2.3').
2014-12-09 16:49:23.263948     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputRoot'' at ('MyService_SetCustomDict.CopyEntireMessage', '2.20'). This resolved to ''InputRoot''. The result was ''ROW... Root Element Type=16777216 NameSpace='' Name='Root' Value=NULL''.
2014-12-09 16:49:23.263990     9664   UserTrace   BIP2568I: Node 'MyService.Compute': Copying sub-tree from ''InputRoot'' to ''OutputRoot''.
2014-12-09 16:49:23.264244     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''SET OutputLocalEnvironment = InputLocalEnvironment;'' at ('MyService_SetCustomDict.Main', '6.3').
2014-12-09 16:49:23.264310     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputLocalEnvironment'' at ('MyService_SetCustomDict.Main', '6.30'). This resolved to ''InputLocalEnvironment''. The result was ''ROW... Root Element Type=16777216 NameSpace='' Name='Root' Value=NULL''.
2014-12-09 16:49:23.264360     9664   UserTrace   BIP2568I: Node 'MyService.Compute': Copying sub-tree from ''InputLocalEnvironment'' to ''OutputLocalEnvironment''. 
2014-12-09 16:49:29.077280     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''DECLARE myBlob BLOB;'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '58.4').
2014-12-09 16:49:30.301434     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''SET myBlob = CAST(InputRoot.SOAP.Body.nsx:SearchDataResponse.nsx:SearchDataResult AS BLOB CCSID InputProperties.CodedCharSetId ENCODING InputProperties.Encoding);'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '60.4').
2014-12-09 16:49:31.317042     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputRoot.SOAP.Body.nsx:SearchDataResponse.nsx:SearchDataResult'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '60.24'). This resolved to ''InputRoot.SOAP.Body.http://xyz:SearchDataResponse.http://xyz:SearchDataResult''. The result was '''<![CDATA[<innerMsg><a></a></innerMsg>]]>'''.
2014-12-09 16:49:31.317136     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputProperties.CodedCharSetId'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '60.102'). This resolved to ''InputProperties.CodedCharSetId''. The result was ''1208''.
2014-12-09 16:49:31.317180     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputProperties.Encoding'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '60.142'). This resolved to ''InputProperties.Encoding''. The result was ''546''.
2014-12-09 16:49:31.317252     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''CAST(InputRoot.SOAP.Body.nsx:SearchDataResponse.nsx:SearchDataResult AS BLOB CCSID InputProperties.CodedCharSetId ENCODING InputProperties.Encoding)'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '60.17'). This resolved to ''CAST('<![CDATA[<innerMsg><a></a></innerMsg>]]>' AS BLOB CCSID 1208 ENCODING 546 )''. The result was ''X'3c215b43444154415b3c696e6e65724d73673e3c613e3c2f613e3c2f696e6e65724d73673e5d5d3e'''.
2014-12-09 16:49:31.317336     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''CREATE LASTCHILD OF OutputRoot.XMLNSC DOMAIN 'XMLNSC' PARSE(myBlob, InputProperties.Encoding, InputProperties.CodedCharSetId);'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '61.4').
2014-12-09 16:49:33.757612     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''myBlob'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '61.66'). This resolved to ''myBlob''. The result was ''X'3c215b43444154415b3c696e6e65724d73673e3c613e3c2f613e3c2f696e6e65724d73673e5d5d3e'''.
2014-12-09 16:49:33.757704     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputProperties.Encoding'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '61.74'). This resolved to ''InputProperties.Encoding''. The result was ''546''.
2014-12-09 16:49:33.757744     9664   UserTrace   BIP2539I: Node '': Evaluating expression ''InputProperties.CodedCharSetId'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '61.100'). This resolved to ''InputProperties.CodedCharSetId''. The result was ''1208''.
2014-12-09 16:49:33.757876     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''DECLARE i INTEGER 1;'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '69.4').
2014-12-09 16:49:33.835520     9664   UserTrace   BIP5004E: An XML parsing error ''The markup in the document preceding the root element must be well-formed.'' occurred on line 1 column 3 when parsing element ''/Root/XMLNSC/XMLNSC''. 
                                       Internal error codes are '1511' and '2'.
                                       This error was reported by the generic XML parser, and is usually the result of a badly formed XML message.
                                       Check that the input XML message is a well-formed XML message that adheres to the XML specification. The line number and column number that are quoted in the message give the position where the parser discovered the problem. However, the actual error might be earlier in the message. 
                                       Other possible causes are: 
                                       1. A character that is not supported by XML occurs in the instance message data. 
                                            XML supports only a subset of control characters; therefore, ensure that no unsupported characters, such as X'00', appear in the document. 
                                       2. The Coded Character Set ID that is defined in the message header does not reflect the contents of the instance message. 
                                            If the XML document has an XML prologue, the WebSphere MQ CodedCharSetId should be consistent with the XML Encoding field. 
                                       3. A reserved XML character appears in the instance message data. 
                                            Characters that might be recognized as XML markup - for example, < and & - should be replaced with the corresponding XML entities - &lt; and &amp;.
2014-12-09 16:49:36.045800     9664   UserTrace   BIP2537I: Node 'MyService.Compute': Executing statement   ''FOR source AS Environment.Variables.SearchDataResponse.XMLNSC.root.dane[ ] DO ... END FOR;'' at ('MyService_SetCustomDict.SetCustomDictMessageSearchDataResponse', '70.4').

Threads encountered in this trace:
  12100  6820  9664  9768


Quote:
Also, please can you check that the XML and code that you posted is exactly what was used when generating the user trace.

XML is the same, code is changed by me to anonymouse identifiers, namespaces, service names etc (user trace is also anonymoused). If data in this thread are unclear I will prepare additional broker project for the purpose of this issue.
Back to top
View user's profile Send private message
Simbu
PostPosted: Wed Dec 10, 2014 1:48 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Below code works for me in V8.0.0.4 for your first post

Code:
DECLARE xmlString CHARACTER InputRoot.XMLNSC.*:Envelope.*:Body.*:SearchDataResponse.(XMLNSC.CDataField)*:SearchDataResult;
CREATE LASTCHILD OF Environment.Variables.msg DOMAIN 'XMLNSC' PARSE (xmlString, InputProperties.Encoding, InputProperties.CodedCharSetId);


in your case, if i'm correct, the code should be like as your using SOAP Domain

Code:
DECLARE xmlString CHARACTER InputRoot.SOAP.Body.*:SearchDataResponse.(XMLNSC.CDataField)*:SearchDataResult;
CREATE LASTCHILD OF Environment.Variables.msg DOMAIN 'XMLNSC' PARSE (xmlString, InputProperties.Encoding, InputProperties.CodedCharSetId);


and ensure that xmlString has
Code:
xmlString:CHARACTER:<innerMsg><a></a></innerMsg>
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Dec 10, 2014 1:56 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Simbu: Did you use a SOAPInput or a SOAPRequest when testing your scenario?
_________________
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
Simbu
PostPosted: Wed Dec 10, 2014 2:17 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

kimbert wrote:
Simbu: Did you use a SOAPInput or a SOAPRequest when testing your scenario?


I tried with SOAPInput node but not SOAPRequest node.
Back to top
View user's profile Send private message
dziku007
PostPosted: Fri Dec 12, 2014 11:33 am    Post subject: Reply with quote

Apprentice

Joined: 26 Jul 2012
Posts: 32

Hi,

After Your suggestions I found where I had a mistake. There was all ok with code on service client side. As we can see on this thread (and many others) code to parse CDATA that works is similar to
Code:
DECLARE xmlString CHARACTER InputRoot.XMLNSC.*:Envelope.*:Body.*:SearchDataResponse.*:SearchDataResult;
CREATE LASTCHILD OF Environment.Variables.msg DOMAIN 'XMLNSC' PARSE (xmlString, InputProperties.Encoding, InputProperties.CodedCharSetId);


What I did wrong was how I set CDATA in my mock service (the server side) in mapping node using simple Assign.
This was wrong:
Code:
<![CDATA[<innerMsg><a></a></innerMsg>]]>


I don't know if there is any method to assing explicitly CDATA in mapping node. It seems that we can do such assignment using ESQL as in http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67174_.htm.

To return xml using Assign in mapping node this works:
Code:
<innerMsg><a></a></innerMsg>

(if you don't use any xml special characters)

This works better(escaped regular xml file):
Code:
&lt;innerMsg&gt;&lt;a&gt;&lt;/a&gt;&lt;/innerMsg&gt;

(because You can use any special characters)

After all when i connected to real service that returns CDATA CREATE... PARSE worked. It seems that broker is parsing CDATA internally (while populating message tree) leaving pure xml string in a tree node)

Anyway, thanks again for Your help and sorry for my silly mistake
Back to top
View user's profile Send private message
kimbert
PostPosted: Sat Dec 13, 2014 4:30 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
It seems that broker is parsing CDATA internally (while populating message tree) leaving pure xml string in a tree node)
Yes, that's exactly what it does. Any other design would be incorrect ( the CDATA markup is not part of the data ). The CDATA-ness of the content is marked in the tree using the field type XMLNSC.CDataField, as described in the knowledge center.
_________________
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
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Trouble with parsing CDATA from xml message
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.