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 » XML to CWF from C header - end of string question

Post new topic  Reply to topic
 XML to CWF from C header - end of string question « View previous topic :: View next topic » 
Author Message
pcelari
PostPosted: Mon Jul 24, 2006 9:56 am    Post subject: XML to CWF from C header - end of string question Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

it must be a trivial question.

I have C structure like this:

struct Order {
char ONumber[11];
char ItemId[13];
};

under C, the last char is always reserved for the '\0'. However, I need the end msg to be fix length string of 23-char long, with 0-9 for ONum, and 10-21 for ItemId, followed by a single '\0' at the end.

Do I need to alter the length of each item after importing the structure?

thanks a lot.
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jul 24, 2006 11:45 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I need the end msg to be fix length string of 23-char long, with 0-9 for ONum, and 10-21 for ItemId, followed by a single '\0' at the end.
It's very rare to find a fixed-length field which is null-terminated. Are you sure that this is what you want to do?
Quote:
Do I need to alter the length of each item after importing the structure?

Your problem is bigger than that, I think. If you define these strings as 'fixed-length' the CWF writer will not null-terminate the second string. (Why would it?). If you want a fixed-length field with a \0 at the end, you will have to insert the \0 yourself.
I'll leave you to do the byte-counting yourself. Or you could always just give it a try and see what happens
Back to top
View user's profile Send private message
pcelari
PostPosted: Mon Jul 24, 2006 12:21 pm    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

thanks for the response. I think I should include comment to my structure:

struct Order {
char ONumber[11]; /* 10-digit OrderNumber + 1 for terminating null */
char ItemId[13]; /* 12-digit ItemId + 1-char for terminating null */
};

The protocol for the msg is based on this structure, but without the '\0' in between. Otherwise, the recipient won't receive the whole msg rather only the first one and treat the msg as 10-char long when it read the '\0' at position 11.

an example of such a msg:
"1234567890ABCDEFGHIJKL'\0'"

Quote:
If you want a fixed-length field with a \0 at the end, you will have to insert the \0 yourself.


You're right. I can always add one-character filler to the CWF msg and set it to be a fixed '\0'.
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
pcelari
PostPosted: Mon Jul 24, 2006 12:27 pm    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

and it would also mean I'll need to edit the length field in the msg set editor to reduce the length of each element by one, and add one field. This corresponds to importing the following altered structure:

struct Order {
char ONumber[10]; /* 10-digit OrderNumber, no terminating null */
char ItemId[12]; /* 12-digit ItemId, no terminating null */
char filler[1]; /*** only for terminating null ***/
};

Am I right? Any other input?
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jul 24, 2006 1:39 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
You're right. I can always add one-character filler to the CWF msg and set it to be a fixed '\0'
If you feel brave you could use the TDS format instead, and define a Group Terminator of \0 for the structure. That way, you don't have to write any ESQL, and all the information about your message structure is in your message set ( which is a Very Good Idea ).
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jul 24, 2006 1:58 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

pcelari might run into some issues using TDS if all of his data is not represented as strings of some kind or another.

pcelari - can you be a bit more specific about the source application and the destination application? Are you trying to process this message as an input, or produce it as an output, or both? Is the structure the same on both sides, with some differences in things like null-terminators - or is the structure completely different?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
pcelari
PostPosted: Tue Jul 25, 2006 9:31 am    Post subject: Reply with quote

Chevalier

Joined: 31 Mar 2006
Posts: 411
Location: New York

jefflowrey wrote:
pcelari might run into some issues using TDS if all of his data is not represented as strings of some kind or another.

pcelari - can you be a bit more specific about the source application and the destination application? Are you trying to process this message as an input, or produce it as an output, or both? Is the structure the same on both sides, with some differences in things like null-terminators - or is the structure completely different?


Yes, they are all strings. the CWF from C structure is at the legacy end. the input msg is MRM XML. What I'm doing is to use a Mapping Node to perform the mapping, while let the CWF to construct the physical byte stream, plus the terminating zero.
_________________
pcelari
-----------------------------------------
- a master of always being a newbie
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Jul 25, 2006 2:09 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You can get away without the char filler[1]. Just set the Physical Type of ItemId to 'null-terminated string' and the CWF writer will put in the \0 for you.
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 » XML to CWF from C header - end of string question
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.