Why are you creating a list containing one map entry for the message?  It 
doesn't appear to me that you need to do that as you just have one map 
class entry that you're sending in your message.  In your c++ code, don't 
append the map to logList (in fact don't create logList at all).  Just 
send the marshalled map class as the message (like you are doing in your 
Java code) and then expect the message to be a marshalled map class (not a 
marshalled list of map classes) when receiving the message. 

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




From:   "Dedhia, Hardik" <hardik.ded...@netapp.com>
To:     Sharon Lucas/Austin/IBM@IBMUS
Date:   07/27/2011 10:20 AM
Subject:        RE: Marshalling problem



Yes what you mentioned is right.
 
Here’s the output:
 
@SDT/*:410:@SDT/{:316::13:map-class-map@SDT/{:288::19:STAF/Test/LogRecord@SDT/{:254::4:keys@SDT/[3:198:@SDT/{:56::12:display-name@SDT/$S:7:Message:3:key@SDT/$S:7:message@SDT
    
/{:56::12:display-name@SDT/$S:9:Parameter:3:key@SDT/$S:5:param@SDT/{:56::12:display-name@SDT/$S:9:New
 
value:3:key@SDT/$S:5:value:4:name@SDT/$S:19:STAF/Test/LogRecord@SDT/%:7    
3::19:STAF/Test/LogRecord@SDT/$S:6:MODIFY@SDT/$S:10:ITERATIONS@SDT/$S:3:200
 
In my c++ code, I was appending the map to logList. Could that be causing 
the exception? 
 
It seems I have this piece of code in C++ which I don’t use in JAVA (when 
marshalling the data):
 
STAFObjectPtr logList = STAFObject::createList();
//add entries to map modifyRecord
logList->append(modifyRecord);
 
Is there API similar to this for JAVA?
 
Thanks,
 
Hardik.
 
From: Sharon Lucas [mailto:luc...@us.ibm.com] 
Sent: Wednesday, July 27, 2011 11:11 AM
To: Dedhia, Hardik
Cc: staf-users@lists.sourceforge.net
Subject: Re: Marshalling problem
 
Your Java code is assigning a marshalled map class instance as the message 
string with type "Modify" and is sending that message. 

Your C++ code that you provided starts with line: 

STAFString message = queueMap->get("message")->asString(); 

So, it appears you have already iterated through the message list from a 
QUEUE LIST request and are processing an entry in this message list and 
this line is obtaining the message string from a queued message.  So, 
since your Java code is assigning a marshalled map class instance to the 
message string, your C++ code should be expecting a marshalled map class 
instance.  However, your C++ code is expecting the message to be a 
marshalled list so it is failing when you try to assigning the 
unmarshalled root object  (a map class object) to a list. 
  
You are printing the marshalled message in your C++ code as follows. 
Please provide the exact complete content of that marshalled message. That 
will show me exactly what type of message it is (and confirm whether what 
I described above is happening). 

cout << message << endl; 

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




From:        "Dedhia, Hardik" <hardik.ded...@netapp.com> 
To:        <staf-users@lists.sourceforge.net>, Sharon 
Lucas/Austin/IBM@IBMUS 
Date:        07/27/2011 09:50 AM 
Subject:        Marshalling problem 





Hi, 
  
I am trying to send messages from a Java Interface to a c++ program using 
the following code: 
  
STAFHandle modify_handle = handle; 
             STAFMapClassDefinition modifyClass = new 
STAFMapClassDefinition("STAF/Test/LogRecord"); 
             modifyClass.addKey("message", "Message"); 
             modifyClass.addKey("param", "Parameter"); 
             modifyClass.addKey("value", "New value"); 
              
             STAFMarshallingContext mc = new STAFMarshallingContext(); 
             mc.setMapClassDefinition(modifyClass); 
              
             Map modifyRecord = modifyClass.createInstance(); 
              
             modifyRecord.put("message", "MODIFY"); 
             modifyRecord.put("param", "ITERATIONS"); 
             modifyRecord.put("value", "200"); 
  
             mc.setRootObject(modifyRecord); 
             String send = mc.marshall(); 
             String wrappedMessage = STAFUtil.wrapData(send); 
             System.out.println(wrappedMessage + hammer_handle); 
             modify_handle.submit2(cyclMachine, "QUEUE", "QUEUE TYPE 
Modify MESSAGE " + wrappedMessage + " HANDLE " + hammer_handle); 
  
On the c++ code side, I use a QUEUE LIST to obtain the queued messages and 
process them. In Case of messages with TYPE Modify – this is the code I 
use to un-marshall the map: 
  
STAFString message = queueMap->get("message")->asString(); 
259         cout << message << endl; 
260         STAFObjectPtr mc = STAFObject::unmarshall(message, 
kSTAFIgnoreIndirectObjects); 
261         STAFObjectPtr modifyList = mc->getRootObject(); 
262         STAFObjectIteratorPtr iter = modifyList->iterate(); 
263 
264         while(iter->hasNext()) 
265         { 
266                 STAFObjectPtr modifyQueueMap = iter->next(); 
267                 STAFString messg = 
modifyQueueMap->get("message")->asString(); 
268                 param = modifyQueueMap->get("param")->asString(); 
269                 value = modifyQueueMap->get("value")->asString(); 
270                 //param = param_str.c_str(); 
271                 //value = value_str.c_str(); 
272                 cout << "Message: " << messg << endl 
273                         << "Parameter to be changed: " << param << 
endl 
274                         << "New Value : " << value << endl; 
275 
276                 int corrNum = NameConv(messg, handle_from); 
277                 int perform_action = perform_action = 
SwitchCase(corrNum); 
278                 int act_prfmd = 0; 
279                 if(perform_action == 1) 
280                         act_prfmd = switch_to_action(corrNum, 
handle_from); 
281                 return corrNum; 
282 
283         } 
  
It was working fine when I was sending messages to and from c++ programs 
but when I added the Java interface it gives me : 
  
terminate called after throwing an instance of 
'STAFInvalidObjectException' 
  
Can you please point me to the fault in my code? 
  
Thanks so much, 
  
Hardik. 

<<image/gif>>

------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to