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 » conversion Type string to XML format

Post new topic  Reply to topic Goto page 1, 2  Next
 conversion Type string to XML format « View previous topic :: View next topic » 
Author Message
SABCAS
PostPosted: Tue Feb 21, 2006 6:31 am    Post subject: conversion Type string to XML format Reply with quote

Acolyte

Joined: 09 Mar 2005
Posts: 60
Location: Switzerland

Hallo,
I have the following string :
![CDATA[<SIFM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BasWfmState.xsd"><!-- Domain : WFM --><!-- Author : Swisscom IT Services AG, IT-PDL --><!-- Contact : sif.message@swisscom.com --><!-- Purpose : xml sample file --><!-- Interface : OMHS_0033_WFMServiceOrderState (V1) --><!-- Function : BasWfmState --><!-- DataObject : WfmStateBas (V1) --><!-- Export : 19.01.2006 17:14:26 by SIF-MCR --> <Header id="a"> <Requester> <ApplicationID application="com.swisscom.wfm" bo="" /> </Requester> <BSR function="BasWfmState" revision="1"> <ApplicationID application="com.swisscom.baskal.1" bo="" /> </BSR> <Environment language="" opCode="" prefix="" testFlag=""> <Timestamp>2005-11-28T09:30:47+01:00</Timestamp> </Environment> <FunctionHeader functionType="Datagramm" priorityType="medium" responseType="onExecution" returnCode="failed" /> </Header> <WfmStateBas> <WfmTask> <StateText>completed</StateText> <StateCode>1</StateCode> <StateDate>2005-12-24T13:36:00+01:00</StateDate> <Visum>tgdscju4</Visum> <Message>Test abgeschlossen</Message> </WfmTask> <ErrorStatus> <ErrorComponent>BAS</ErrorComponent> <ErrorCode>123456789</ErrorCode> <ErrorText>invalid content of Business Object</ErrorText> <ErrorDetail>BaskalExNr:2004/TechInfo:CircuitOrderKey field is not of Type Integer</ErrorDetail> </ErrorStatus> <BaskalOrderTask> <TaskListKey>17</TaskListKey> <BaskalCode>INAR</BaskalCode> <BaskalOrderId> <CircuitCode>235479</CircuitCode> <CircuitOrderKey>1400493</CircuitOrderKey> </BaskalOrderId> </BaskalOrderTask> </WfmStateBas></SIFM>]]

and I would like to convert into XML document:

<SIFM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BasWfmState.xsd">
<!-- Domain : WFM -->
<!-- Author : Swisscom IT Services AG, IT-PDL -->
<!-- Contact : sif.message@swisscom.com -->
<!-- Purpose : xml sample file -->
<!-- Interface : OMHS_0033_WFMServiceOrderState (V1) -->
<!-- Function : BasWfmState -->
<!-- DataObject : WfmStateBas (V1) -->
<!-- Export : 19.01.2006 17:14:26 by SIF-MCR -->
<Header id="a">
<Requester>
<ApplicationID application="com.swisscom.wfm" bo=""/>
</Requester>
<BSR function="BasWfmState" revision="1">
<ApplicationID application="com.swisscom.baskal.1" bo=""/>
</BSR>
<Environment language="" prefix="" testFlag="" opCode="">
<Timestamp>2005-11-28T09:30:47+01:00</Timestamp>
</Environment>
<FunctionHeader functionType="Datagramm" responseType="onExecution" priorityType="medium" returnCode="failed"/>
</Header>
<WfmStateBas>
<WfmTask>
<StateText>completed</StateText>
<StateCode>1</StateCode>
<StateDate>2005-12-24T13:36:00+01:00</StateDate>
<Visum>tgdscju4</Visum>
<Message>Test abgeschlossen</Message>
</WfmTask>
<ErrorStatus>
<ErrorComponent>BAS</ErrorComponent>
<ErrorCode>123456789</ErrorCode>
<ErrorText>invalid content of Business Object</ErrorText>
<ErrorDetail>BaskalExNr:2004/TechInfo:CircuitOrderKey field is not of Type Integer</ErrorDetail>
</ErrorStatus>
<BaskalOrderTask>
<TaskListKey>17</TaskListKey>
<BaskalCode>INAR</BaskalCode>
<BaskalOrderId>
<CircuitCode>235479</CircuitCode>
<CircuitOrderKey>1400493</CircuitOrderKey>
</BaskalOrderId>
</BaskalOrderTask>
</WfmStateBas>
</SIFM>

How can I do in ESQL Command?
Thanks in advance for your answer and Help.
Ciao
Sabato
Back to top
View user's profile Send private message
EddieA
PostPosted: Tue Feb 21, 2006 11:06 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Maybe the data needs to be PARSEd.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
SABCAS
PostPosted: Tue Feb 21, 2006 10:24 pm    Post subject: Reply with quote

Acolyte

Joined: 09 Mar 2005
Posts: 60
Location: Switzerland

Hallo,
I parsed the data but I receive "No valid body of the document could be found", here it follows my ESQL code:
SET OutputRoot.Properties.Domain='XML';
SET OutputRoot.Properties.MessageFormat='XML';
SET OutputRoot.Properties.MessageSet='XML';
SET OutputRoot.Properties.MessageType = '';
SET OutputRoot.Properties.Transactional = TRUE;
SET OutputRoot.Properties.Persistence = FALSE;


SET Environment.Variables.Application.inString = CAST(InputRoot."BLOB"."BLOB" AS CHAR CCSID 850);
SET I = POSITION('&lt;SIFM' IN Environment.Variables.Application.inString);
SET J = POSITION(']]' IN Environment.Variables.Application.inString);
SET leng = LENGTH(Environment.Variables.Application.inString);
SET Environment.Variables.Application.input = SUBSTRING(Environment.Variables.Application.inString FROM I FOR J-I);


SET OutputRoot.MQMD.MsgType = MQMT_DATAGRAM;
SET OutputRoot.MQMD.Expiry = MQEI_UNLIMITED;
SET OutputRoot.MQMD.Priority = 0;
SET OutputRoot.MQMD.ReplyToQ = '';
SET OutputRoot.MQMD.ReplyToQMgr = '';
SET OutputRoot.MQMD.Encoding = 546;
SET OutputRoot.MQMD.CodedCharSetId = 819;
SET OutputRoot.MQMD.Format = MQFMT_STRING;
SET OutputRoot.MQMD.PutApplType = MQAT_BROKER;
SET OutputRoot.MQMD.PutApplName = 'WBIMB/XSLTTestFlow';
SET OutputRoot.MQMD.PutDate = CURRENT_GMTDATE;
SET OutputRoot.MQMD.PutTime = CURRENT_GMTTIME;


--Create an XML Declaration
SET OutputRoot.XML.(XML.XmlDecl)='';

--Set the Version within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version)='1.0';

--Set the Encoding within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding")='UTF-8';

SET OutputRoot.XML = Environment.Variables.Application.input;

I suppose that I should parse only the data string.
Ciao
Sabato
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Tue Feb 21, 2006 10:38 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

SABCAS wrote:
Hallo,
"No valid body of the document could be found"

This would mean that the message could not be parsed at the input node itself, it hasent reached your code as yet...

R you using a input message set ??

Regards.
Back to top
View user's profile Send private message Send e-mail
elvis_gn
PostPosted: Tue Feb 21, 2006 10:38 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

SABCAS wrote:
Hallo,
"No valid body of the document could be found"

This would mean that the message could not be parsed at the input node itself, it hasent reached your code as yet...

R you using a input message set ??

Regards.
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Tue Feb 21, 2006 10:46 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

EddieA wrote:
Maybe the data needs to be PARSEd.

Less subtle hint. Look up PARSE in the ESQL documentation. Or try seaching for it, using the ever present, Search button.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
dipankar
PostPosted: Tue Feb 21, 2006 11:53 pm    Post subject: Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

Don't use the following code because it has no valid header tag.
Code:
SET OutputRoot.XML = Environment.Variables.Application.input;


As EddieA has told you before, you have to use parser.
Use the following code
CREATE LASTCHILD OF OutputRoot DOMAIN 'XML' PARSE(Environment.Variables.Application.input)

I hope it will help you out.
_________________
Regards
Back to top
View user's profile Send private message
SABCAS
PostPosted: Wed Feb 22, 2006 2:09 am    Post subject: Reply with quote

Acolyte

Joined: 09 Mar 2005
Posts: 60
Location: Switzerland

Hallo
I used your last suggestion, but I receive from Parser the following:
"String is not of correct form for byte array. Must have even number of characters"

Should I make a CAST before PARSE ?

Thanks for the Help
Ciao
Sabato
Back to top
View user's profile Send private message
SABCAS
PostPosted: Wed Feb 22, 2006 3:39 am    Post subject: Reply with quote

Acolyte

Joined: 09 Mar 2005
Posts: 60
Location: Switzerland

Hallo
I make a little progress, I mean I have the following String:
SET myString = '<?xml version="1.0" encoding="UTF-8"?><SIFM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BasWfmState.xsd"><!-- Domain : WFM --><!-- Author : Swisscom IT Services AG, IT-PDL --><!-- Contact : sif.message@swisscom.com --><!-- Purpose : xml sample file --><!-- Interface : OMHS_0033_WFMServiceOrderState (V1) --><!-- Function : BasWfmState --><!-- DataObject : WfmStateBas (V1) --><!-- Export : 19.01.2006 17:14:26 by SIF-MCR --> <Header id="a"> <Requester> <ApplicationID application="com.swisscom.wfm" bo="" /> </Requester> <BSR function="BasWfmState" revision="1"> <ApplicationID application="com.swisscom.baskal.1" bo="" /> </BSR> <Environment language="" opCode="" prefix="" testFlag=""> <Timestamp>2005-11-28T09:30:47+01:00</Timestamp> </Environment> <FunctionHeader functionType="Datagramm" priorityType="medium" responseType="onExecution" returnCode="failed" /> </Header> <WfmStateBas> <WfmTask> <StateText>completed</StateText> <StateCode>1</StateCode> <StateDate>2005-12-24T13:36:00+01:00</StateDate> <Visum>tgdscju4</Visum> <Message>Test abgeschlossen</Message> </WfmTask> <ErrorStatus> <ErrorComponent>BAS</ErrorComponent> <ErrorCode>123456789</ErrorCode> <ErrorText>invalid content of Business Object</ErrorText> <ErrorDetail>BaskalExNr:2004/TechInfo:CircuitOrderKey field is not of Type Integer</ErrorDetail> </ErrorStatus> <BaskalOrderTask> <TaskListKey>17</TaskListKey> <BaskalCode>INAR</BaskalCode> <BaskalOrderId> <CircuitCode>235479</CircuitCode> <CircuitOrderKey>1400493</CircuitOrderKey> </BaskalOrderId> </BaskalOrderTask> </WfmStateBas></SIFM>'

and now I would it to convert in XML Document, I use:
CREATE LASTCHILD OF OutputRoot DOMAIN 'XML' PARSE(ASBITSTREAM(Environment.Variables.Application.outString2) OPTIONS RootBitStream);

But I receive an Exception from Parser:
<ParserException><File>F:\build\S500_P\src\MTI\MTIforBroker\GenXmlParser2\XmlImbParser.cpp</File><Line>394</Line><Function>XmlImbParser::parseFirstChild</Function><Type></Type><Name></Name><Label></Label><Text>XML Parsing Errors have occurred</Text><Catalog>BIPv500</Catalog><Severity>3</Severity><Number>5009</Number><ParserException><File>F:\build\S500_P\src\MTI\MTIforBroker\GenXmlParser2\XmlBrokerAsgardParser.cpp</File><Line>815</Line><Function>XmlBrokerAsgardParser::error</Function><Type></Type><Name></Name><Label></Label><Text>An error has been reported by the BIPXML4C component.</Text><Catalog>BIPv500</Catalog><Severity>3</Severity><Number>5004</Number><Insert><Type>2</Type><Text>182</Text></Insert><Insert><Type>5</Type><Text></Text></Insert><Insert><Type>2</Type><Text>1</Text></Insert><Insert><Type>2</Type><Text>1</Text></Insert><Insert><Type>5</Type><Text>Invalid document structure</Text></Insert><Insert><Type>5</Type><Text>XML</Text></Insert></ParserException></ParserException></RecoverableException></RecoverableException></EXEPTLIST></ERROR>

I tried with XMLSpy to load and validate my string and it's ok!!!
Why The Parser on WBIMB gives some Problem ?

Thanks for your Help.
Ciao
Sabato
Back to top
View user's profile Send private message
JT
PostPosted: Wed Feb 22, 2006 8:49 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

The BIP5004 error results from a badly formed XML document.

So, to provide clarity, add a Trace node prior to the MQOuput node with the ${Root} pattern. Post the results here.
Back to top
View user's profile Send private message
SABCAS
PostPosted: Wed Feb 22, 2006 10:45 pm    Post subject: Reply with quote

Acolyte

Joined: 09 Mar 2005
Posts: 60
Location: Switzerland

Hallo,
I have added a traceNode prior MqOutputNode but I didn't have received more information, here is what I receive:
sifm = '<?xml version="1.0" encoding="UTF-8"?><SIFM><Header>12345</Header></SIFM>'
)
)
)
(
(0x01000000):Properties = (
(0x03000000):MessageSet = NULL
(0x03000000):MessageType = NULL
(0x03000000):MessageFormat = NULL
(0x03000000):Encoding = NULL
(0x03000000):CodedCharSetId = NULL
(0x03000000):Transactional = UNKNOWN
(0x03000000):Persistence = UNKNOWN
(0x03000000):CreationTime = NULL
(0x03000000):ExpirationTime = NULL
(0x03000000):Priority = NULL
(0x03000000):ReplyIdentifier = NULL
(0x03000000):ReplyProtocol = 'MQ'
(0x03000000):Topic = NULL
)
(0x01000010):XML =

I tried also with a very little XML : sifm = '<?xml version="1.0" encoding="UTF-8"?><SIFM><Header>12345</Header></SIFM>' but the Parser answers always the same "Invalid document structure"
I tried also the following string : '<SIFM><Header>12345</Header></SIFM>' but without successfull.
Thanks for your help.
Ciao
Sabato
Back to top
View user's profile Send private message
dipankar
PostPosted: Thu Feb 23, 2006 12:22 am    Post subject: Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

Hi SABCAS,
Please try with the follwoing code

Code:
CREATE LASTCHILD OF OutputRoot DOMAIN 'XML' PARSE(Environment.Variables.Application.outString2);

--Create an XML Declaration
SET OutputRoot.XML.(XML.XmlDecl)='';

--Set the Version within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version)='1.0';

--Set the Encoding within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding")='UTF-8';


First create messagebody then create declaration part.

Can you check the value populated in Environment.Variables.Application.outString2?
Are you giving input as BLOB? If yes, populate the above environment variable as BLOB.
_________________
Regards
Back to top
View user's profile Send private message
dipankar
PostPosted: Thu Feb 23, 2006 12:58 am    Post subject: Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

I have checked your code in my own system. I am able to create the expected output.

Most probably you are getting the following error
XML parsing error (Invalid document structure) encountered on line 1 column 1 while parsing element XML.

It is because of your input string itself contains '<?xml version="1.0" encoding="UTF-8"?>'.

By the ESQL you are also trying to create that part.
_________________
Regards
Back to top
View user's profile Send private message
SABCAS
PostPosted: Thu Feb 23, 2006 3:51 am    Post subject: Reply with quote

Acolyte

Joined: 09 Mar 2005
Posts: 60
Location: Switzerland

Hallo,
I correct my ESQL code but the conversion from String to BLOB doesn't work.
Could you my Code test:
SET Environment.Variables.Application.sifm = '<SIFM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BasWfmState.xsd"><!-- Domain : WFM --><!-- Author : Swisscom IT Services AG, IT-PDL --><!-- Contact : sif.message@swisscom.com --><!-- Purpose : xml sample file --><!-- Interface : OMHS_0033_WFMServiceOrderState (V1) --><!-- Function : BasWfmState --><!-- DataObject : WfmStateBas (V1) --><!-- Export : 19.01.2006 17:14:26 by SIF-MCR --> <Header id="a"> <Requester> <ApplicationID application="com.swisscom.wfm" bo="" /> </Requester> <BSR function="BasWfmState" revision="1"> <ApplicationID application="com.swisscom.baskal.1" bo="" /> </BSR> <Environment language="" opCode="" prefix="" testFlag=""> <Timestamp>2005-11-28T09:30:47+01:00</Timestamp> </Environment> <FunctionHeader functionType="Datagramm" priorityType="medium" responseType="onExecution" returnCode="failed" /> </Header> <WfmStateBas> <WfmTask> <StateText>completed</StateText> <StateCode>1</StateCode> <StateDate>2005-12-24T13:36:00+01:00</StateDate> <Visum>tgdscju4</Visum> <Message>Test abgeschlossen</Message> </WfmTask> <ErrorStatus> <ErrorComponent>BAS</ErrorComponent> <ErrorCode>123456789</ErrorCode> <ErrorText>invalid content of Business Object</ErrorText> <ErrorDetail>BaskalExNr:2004/TechInfo:CircuitOrderKey field is not of Type Integer</ErrorDetail> </ErrorStatus> <BaskalOrderTask> <TaskListKey>17</TaskListKey> <BaskalCode>INAR</BaskalCode> <BaskalOrderId> <CircuitCode>235479</CircuitCode> <CircuitOrderKey>1400493</CircuitOrderKey> </BaskalOrderId> </BaskalOrderTask> </WfmStateBas></SIFM>'
SET OutputRoot.MQMD.MsgType = MQMT_DATAGRAM;
SET OutputRoot.MQMD.Expiry = MQEI_UNLIMITED;
SET OutputRoot.MQMD.Priority = 0;
SET OutputRoot.MQMD.ReplyToQ = '';
SET OutputRoot.MQMD.ReplyToQMgr = '';
SET OutputRoot.MQMD.Encoding = 546;
SET OutputRoot.MQMD.CodedCharSetId = 819;
SET OutputRoot.MQMD.Format = MQFMT_STRING;
SET OutputRoot.MQMD.PutApplType = MQAT_BROKER;
SET OutputRoot.MQMD.PutApplName = 'WBIMB/SifMpm2Wfm';
SET OutputRoot.MQMD.PutDate = CURRENT_GMTDATE;
SET OutputRoot.MQMD.PutTime = CURRENT_GMTTIME;

DECLARE bodyBlob BLOB ASBITSTREAM(Environment.Variables.Application.sifm, Environment.Variables.Application.Encoding, Environment.Variables.Application.CodeCharSetID);
SET Environment.Variables.Application.BodyBlob = bodyBlob;
CREATE LASTCHILD OF OutputRoot DOMAIN 'XML' PARSE(bodyBlob);
--Create an XML Declaration
SET OutputRoot.XML.(XML.XmlDecl)='';

--Set the Version within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version)='1.0';

--Set the Encoding within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding")='UTF-8';
In Trace Node I check my Varible bodyBlob and is it equal X'' since NULL,
therefore the Parser answer "Invalid Document", something is not clear with a conversion String to BLOB.
Could you help me about the right code to convert String to BLOB ?
Thanks a Lot
Ciao
Sabato
Back to top
View user's profile Send private message
dipankar
PostPosted: Thu Feb 23, 2006 4:11 am    Post subject: Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

Hi,
Instead of using this
Code:
DECLARE bodyBlob BLOB ASBITSTREAM(Environment.Variables.Application.sifm, Environment.Variables.Application.Encoding, Environment.Variables.Application.CodeCharSetID);
SET Environment.Variables.Application.BodyBlob = bodyBlob;

please use the simple code below
Code:
SET Environment.Variables.Application.BodyBlob = CAST([b][i]what everstring[/i][/b] AS BLOB CCSID InputRoot.MQMD.CodedCharSetId);

Because ASBITSTREAM returns a value of type BLOB containing a bit stream representation of the field pointed to by FieldReference and its children.

As your input is BLOB, you can use
SET Environment.Variables.Application.BodyBlob = InputRoot.BLOB.BLOB;
_________________
Regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » conversion Type string to XML format
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.