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 » C Custom node: How to convert incoming message to C string

Post new topic  Reply to topic
 C Custom node: How to convert incoming message to C string « View previous topic :: View next topic » 
Author Message
ktg
PostPosted: Thu Jun 24, 2010 2:00 am    Post subject: C Custom node: How to convert incoming message to C string Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

Hi,

Am writing a UDN(user defined node) in C as we need to communicate with a 3rd party system. 3rd party system provides only C APIs for interaction. The incoming message will be in CSV(Comma seperated values) format which is to be used by custom node to send request to external server. The incoming CSV string has to be partially parsed by user defined node and partial/full csv string has to be passed AS A PARAMETER to C functions. The parameter for the function is of type (char *). How to convert incoming message data to (char *)?

The external system hosts various services. For each service we have corresponding message set. One option we have for getting the concatenated CSV string is, UDN need to parse the incoming message tree(using message set) one by one and adding comma after each element.

Is it the only way or is there is any simpler/better method to achive this?

Please, help.

Thanks,
Kalpana
Back to top
View user's profile Send private message AIM Address
mqjeff
PostPosted: Thu Jun 24, 2010 2:46 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The message that is passed to the UDN should already be constructed in such a way that the UDN does not have to do extensive transformation of it to meet the needs of the node.

The MRM-TDS parser is ideally suited for handling CSV data formats and can easily convert a CSV structure into a logical message tree and can also easily convert a properly built logical message tree into a CSV structure.

A C language (char *) structure is technically defined as a pointer to a char variable. It is usually used as a pointer to a char[] array of characters, and thus a "string". You can easily convert between a char* and a CciString object using the UDN C API's.

You need to go review all of the documentation under this topic:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/as37484_.htm

Read it through a couple of times. Your questions do not indicate a good understanding of the information there.
Back to top
View user's profile Send private message
ktg
PostPosted: Thu Jun 24, 2010 3:07 am    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

Thanks for the reply.

Actually both questions are w.r.t same issue.
I know conversion between char* and CciString. But, inside UDN, I can access message only as type CciElement/CciMessage. (CciElement Name and values can also be extracted). The question is, is there way or function to convert from Element to CciString/Char *
Back to top
View user's profile Send private message AIM Address
mqjeff
PostPosted: Thu Jun 24, 2010 4:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Yes. There is an entire set (or do I mean group?) of method calls to retrieve the contents of a CciElement.
Back to top
View user's profile Send private message
jml
PostPosted: Thu Jun 24, 2010 7:11 pm    Post subject: Reply with quote

Newbie

Joined: 17 Sep 2008
Posts: 4

Use the function cniElementAsBitstream,you can find it in the include file BipCni.h.
Back to top
View user's profile Send private message
ktg
PostPosted: Thu Jun 24, 2010 8:57 pm    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

Yes, there are functions to get value of CciElement like CniElementBitArrayValue, cniElementBooleanValue, cniElementCharacterValue etc., These functions gets the value in the form of (struct CciBitArray*), (CciBool), (CciChar* ) respectively. As I will be sending CSV, i tried to retrive the value as (CciChar* ) using CniElementCharacterValue. But it is not working.
The function cniElementAsBitstream gets the value as (struct CciByteArray*). Again there is no function to convert from (struct CciByteArray*) to (char *)

Btw, I am using blob parser.
Back to top
View user's profile Send private message AIM Address
smdavies99
PostPosted: Thu Jun 24, 2010 9:28 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.

I'm sure the readers of this forum would be interested in why you have chosen this path (UDN) rather than using an existing mechanism to parse & format your message.
CSV generation are there in Broker (and have been since at least 2.0.1 days)
_________________
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
ktg
PostPosted: Thu Jun 24, 2010 10:15 pm    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

I didnt get your question exactly.
If you are asking what is the need of writing UDN?
Am writing a UDN(user defined node) in C as we need to communicate with a 3rd party system. 3rd party system provides only C APIs for interaction. The incoming message will be in CSV(Comma seperated values) format which is to be used by custom node to send request to external server. The incoming CSV string has to be partially parsed by user defined node and partial/full csv string has to be passed AS A PARAMETER to C functions. The parameter for the function is of type (char *).

If you are asking why I am trying for a function to get incoming csv as (char *) instead of parsing Element tree using message set parser?
I thought parsing the tree and extracting element by element would be tedious. At least, I want to make sure that is the ONLY way.
Back to top
View user's profile Send private message AIM Address
smdavies99
PostPosted: Thu Jun 24, 2010 11:41 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.

ktg wrote:


If you are asking why I am trying for a function to get incoming csv as (char *) instead of parsing Element tree using message set parser?
I thought parsing the tree and extracting element by element would be tedious. At least, I want to make sure that is the ONLY way.


Yep, that was what I was asking.

You seem to be wanting to do some mapping between the input model and the message model that the 3rd party app requires.
This is one of the areas where Broker excells. Look at what the Mapping Node can do for you especially in you have the message model that the 3rd party app requires. (you do have this don't you?)

Developing the mapping might indeed be tedious if done in broker but it will be (IMHO) far easier than trying to roll your own in C inside a UDN. Using a 'stub' UDN that sends the data passed to is to a trace file would be the way I'd go. This way, you can really be sure that the data you are sending is right before you get into the troubles you are probably going to encounter with the 3rd part API inside the UDN.
KISS really applies 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
ktg
PostPosted: Fri Jun 25, 2010 12:21 am    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

Mapping required to convert data to the format required by 3rd party system is done using mapping node.
After that, converted message would be passed to UDN. I would get data in UDN as CciMessage type which will be having data in CSV format. Now I need to create a (char *) corresponding to the in coming message and pass it to a function provided by 3rd party system.

How to get that CSV string from CciMessage is my question

Thanks,
Kalpana
Back to top
View user's profile Send private message AIM Address
mgk
PostPosted: Fri Jun 25, 2010 12:44 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Lookup cniElementAsBitstream in the docs, topic as07885.

Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
ktg
PostPosted: Fri Jun 25, 2010 12:47 am    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

The function cniElementAsBitstream gets the value as (struct CciByteArray*). Again, there is no function to convert from (struct CciByteArray*) to (char *)


Thanks,
Kalpana
Back to top
View user's profile Send private message AIM Address
mgk
PostPosted: Fri Jun 25, 2010 1:12 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

But that byte array is the hexbinary version of your whole message. Once you have that you can easily write code in C to convert that to char*...
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
ktg
PostPosted: Fri Jun 25, 2010 4:04 am    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

Thanks for the reply. It made me to think further in that direction and I got it working

Here is the code snippet
Code:
     
{
      struct CciByteArray *Blob = NULL;
      char *msgData;
       
      Blob = (struct CciByteArray *)malloc(sizeof(struct CciByteArray));
      Blob->pointer = (char *)malloc(sizeof(char) * 10240);
      Blob->size    = 10240;

      blobSize = cniElementByteArrayValue(&rc, blobElement, Blob);

      fprintf(outputFile, "%d = cniElementByteArrayValue rc = %d\n", blobSize, rc);
      fflush(outputFile);          

      msgData = (char *) malloc (Blob->size + 1);
      memcpy(msgData, (char *)Blob->pointer, Blob->size);
      msgData[Blob->size] = '\0';
      fprintf(outputFile, "elementValue = %s ",msgData );
      fflush(outputFile);              
}

Thanks for all the inputs

Kalpana
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » C Custom node: How to convert incoming message to C string
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.