Author |
Message
|
Sonal |
Posted: Fri Dec 10, 2010 12:22 pm Post subject: Use of CWF and TDS together |
|
|
Apprentice
Joined: 20 Mar 2009 Posts: 45
|
Hi Experts,
I've a requirement wherein Im getting an XML request message and our MB broker has to transform it into a message such that, the first 100 bytes of the mesg is in Fixed layout and the rest of the mesg in tilde (~) separated format. I've done from XML to Fixed layout by making the wire format as 'CWF'. And for XML to tilde by making the message format as 'TDS'. But here, a part of the XML message has to be tranformed into Fixed record and the other part in TDS. Final message from broker will be the combonation of both.
Is there a way in which I can accomodate two type of wire format into a single output message?
Sample input XML:
<Message>
<Header>
<Name>John</Name>
<Address>USA</Address>
<Phone>2487895634</Phone>
<DOB>101075</DOB>
</Header>
<Body>
<Children>2</Children>
<Employer>IBM</Employer>
<Country>USA</Country>
<State>MI</State>
</Body>
</Message>
Sample output:
JohnUSA24878956341010752~IBM~USA~MI%%
PLease help me...
Many thanks in advance. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Dec 10, 2010 12:27 pm Post subject: Re: Use of CWF and TDS together |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sonal wrote: |
Is there a way in which I can accomodate two type of wire format into a single output message? |
Yes. Please review the samples, the documentation, the tutorial in this forum someplace and the posts of kimbert.
Then please post again if you have specific problems. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Dec 10, 2010 12:49 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
There doesn't appear to be a reason to use CWF at all. |
|
Back to top |
|
 |
Sonal |
Posted: Fri Dec 10, 2010 1:01 pm Post subject: |
|
|
Apprentice
Joined: 20 Mar 2009 Posts: 45
|
Then, how can it be achieved by just using TDS? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Dec 10, 2010 1:06 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Sonal wrote: |
Then, how can it be achieved by just using TDS? |
TDS handles fixed width fields just as easily as delimited fields.
You just have to construct the model correctly. |
|
Back to top |
|
 |
Sonal |
Posted: Fri Dec 10, 2010 1:08 pm Post subject: |
|
|
Apprentice
Joined: 20 Mar 2009 Posts: 45
|
Ok. To be more specific, the problem is...
Requesting system is sending one XML input in two parts. The first one is a standard header that we maintain for all the requesting system. And, the second part is the payload which is application specific.
Now when the first part i.e the header is transformed into FR, the length has to be 100 bytes. Having said that i mean to say, suppose the value of a field in XML is '23' but the max length for it is 5... then in the transofrmed request mesg it must come as '00023'.
The target system while processing the request mesg simply discard the first 100 bytes and then starts processeing the application mesg.
So, is there a way to do so without using CWF or just TDS alone?
pls help... im trying to find the posts by kimbert... came across several posts regarding TDS but havent found anything pertaining similar to this...
Pls help... thankss... |
|
Back to top |
|
 |
kimbert |
Posted: Fri Dec 10, 2010 2:00 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
TDS has always supported fixed length text fields. Since v6.1, TDS has also supported all of the non-text physical types that CWF offers. So it's highly likely that TDS can do everything that you need.
Quote: |
Now when the first part i.e the header is transformed into FR, the length has to be 100 bytes. Having said that i mean to say, suppose the value of a field in XML is '23' but the max length for it is 5... then in the transformed request mesg it must come as '00023'. |
That looks like a text number with fixed length of 5 and left-padded with zeros. In CWF that's an external decimal with length 5 and pad char zero. In TDS it's an integer with length 5 and physical type Text and padding character zero. Presumably there are other, non-integer fields in the header, but you should be able to do what you need to in TDS. If not, please explain clearly what you cannot do.
Quote: |
The target system while processing the request mesg simply discard the first 100 bytes and then starts processing the application mesg. |
Great. So you *could* just create a message definition for the second part, and simply add 100 space characters onto the front before you write out the message. I'm not saying that you *should* do that - there may be a good reason why the architect decided to specify this header. |
|
Back to top |
|
 |
Sonal |
Posted: Fri Dec 10, 2010 2:02 pm Post subject: |
|
|
Apprentice
Joined: 20 Mar 2009 Posts: 45
|
Just to rephrase my problem:
Consider this:
Fields Max length
Name 10
Address 10
Phone 10
DOB 10
Children 1
Employer 10
Country 6
State 2
Now, as per my situation, the input XML is as follows:
<Message>
<Header>
<Name>John</Name>
<Address>USA</Address>
<Phone>2487895634</Phone>
<DOB>101075</DOB>
</Header>
<Body>
<Children>2</Children>
<Employer>IBM</Employer>
<Country>USA</Country>
<State>MI</State>
</Body>
</Message>
In output, the fields from Name to DOB needs to be generated in fixed layout i.e with proper length n padding characters.
John USA 24878956340000101075
Hence, no matter how the input values are... the first part of my transformed output mesg has to be 40 bytes. This part of mesg will be discarded by the target end. It will simply remove the first 40 bytes and then start processeing. But, as per the standard, we've to maintain this 40 bytes attached to the payload (application specific data) while sending to target system.
However, for the rest of the XML... I want a tilde (~) separated mesg.
So, my complete mesg becomes :
John USA 24878956340000101075~IBM~USA~MI%%
Thats why i thought that the first part of XML mesg wud be parsed like CWF format and the rest in TDS.
Correct me if my understandning of problem and assumptions are wrong n if we cud do it in more smarter way.
pls help...
Thanks a ton! |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Dec 10, 2010 2:45 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Construct a TDS model.
The message has two children.
One is an element of a type that contains the definition of the components of your "John USA 24878956340000101075".
The second is an element of a type that contains the definition of the components of your "~IBM~USA~MI%%".
What is the issue here? What are you failing to get? |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Dec 10, 2010 2:46 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
To be fair, I am using the phrase "an element of the type".
It may not strictly end up being an actual element. It may, for example, be the type itself. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Dec 10, 2010 3:07 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Hence, no matter how the input values are... the first part of my transformed output mesg has to be 40 bytes. This part of mesg will be discarded by the target end. It will simply remove the first 40 bytes and then start processeing. But, as per the standard, we've to maintain this 40 bytes attached to the payload (application specific data) while sending to target system.
However, for the rest of the XML... I want a tilde (~) separated mesg. |
You seem to have a poor understanding of what the TDS parser can do. It can parse/write fixed length and delimited data in the same message.
You need two complex elements in your message, each with its own complex type. You need to set the TDS property 'Data Element Separation' to 'Fixed Length' in the first complex type, and 'All Elements Delimited' in the second complex type. |
|
Back to top |
|
 |
|