[omniORB] omniORB.cdr(Un)marshal() - problem

frank grunewald grunewald.f@gmx.de
Tue Apr 29 10:13:02 2003


Hi all,

I hope somebody can give me an idea to solve the problem I have with
"omniORB.cdr(Un)marshal() " on Win2000 PC (omniORB 4.0.1 and omniORBpy2.1).

Short description concerning what I'm trying to do:

I have programed a client server application using CORBA. The client
receives data from the server as described via IDL (IDL see below). After
receiving the data, the client is CDR-coding the TypeCode of the sent data
type and the data itself using "omniORB.cdrMarshal()". Both, the 
CDR-coded TypeCode and the CDR-coded data are written into separate files 
(one for the CDR-TypeCode, another one for the CDR-coded data). 
If I decode the data in the client itself using "omniORB.cdrUnmarshal() ",
it works properly.

Here is the
code
fragment:

#--cdrMarshal
CDROfTC=omniORB.cdrMarshal(CORBA.TC_TypeCode,
CORBA.TypeCode(stringTest.stringInStruct.KomplexDatatype_t))
CDROfStruct=omniORB.cdrMarshal(CORBA.TypeCode(stringTest.stringInStruct.KomplexDatatype_t),
datatype_tFromServer)
tcFileObj=open('e:/usr/python22/xmltest2/CDRTypeCode.txt','wb')
dataFileObj=open('e:/usr/python22/xmltest2/CDRData.txt','wb')
tcFileObj.write(CDROfTC)
dataFileObj.write(CDROfStruct)
tcFileObj.close()
dataFileObj.close()

#-- cdrUnmarshal
tc=omniORB.cdrUnmarshal(CORBA.TC_TypeCode, CDROfTC)
data=omniORB.cdrUnmarshal(tc, CDROfStruct)

Now I have written another program which uses the stored CDR-coded files of
the client. As long the data sent to the client does not contain a string it
works fine. If the sent struct contains a string I receive the 
OS-Message: "... 'read' could not be executed on memory 0x000000...".
No exception at all!?

To make it more simple for you, I wrote CDRDecoder_simple.py, where I
initialise two variables directly with the hex-dump of the CDR-coded files.
The first part works properly (without string), the second part crashes
(with string). I don't understand why. Is there any explanation for this
behaviour?



#-- CDRDecoder_simple
#
#
#!/usr/bin/env python

from omniORB import CORBA
import omniORB


#------------ data without string  !!! OK !!! -----------------
#-- create
variable
containing
the
CDR
coded
TypeCode
CDROfTC_woString='\x01\x00\x00\x00\x0f\x00\x00\x00\xfc\x00\x00\x00\x01+\x88w4\x00\x00\x00IDL:stringTest/stringInStruct/KomplexDatatype_t:1.0\x00\x12\x00\x00\x00KomplexDatatype_t\x00\x00\x00\x04\x00\x00\x00\x03\x00\x00\x00pi\x00\x00\x06\x00\x00\x00\x05\x00\x00\x00data\x00\x00\x00\x00\x15\x00\x00\x00d\x00\x00\x00\x01\x00\x00\x001\x00\x00\x00IDL:stringTest/stringInStruct/DataSequence_t:1.0\x00\x00\x00\x00\x0f\x00\x00\x00DataSequence_t\x00\x00\x13\x00\x00\x00\x0c\x00\x00\x00\x01\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00xPos\x00T\x1a\x01\x03\x00\x00\x00\x05\x00\x00\x00yPos\x00\x03\x00\x01\x03\x00\x00\x00'
#-- create variable containing the CDR coded data
CDROfStruct_woString='\x01\x00\x00\x00\xc3\xf5H@\x18\x00\x00\x00A sequence
of characterso\x00\x00\x00+\x02\x00\x00'

#-- cdrUnmarshal CDR coded contents
try:
  tc=omniORB.cdrUnmarshal(CORBA.TC_TypeCode, CDROfTC_woString)
  data=omniORB.cdrUnmarshal(tc, CDROfStruct_woString)   #-- ok!!
except:
    print "Error! -- omniORB.cdrUnmarshal"

print "!\n", "!\n","!\n","!\n","!\n","!\n","!\n", \
      "CDRDecoder found the following after cdrUnmarshal: \n", \
      "pi   : ",data.pi, "\n", "data : ",data.data, "\n", \
      "xPos : ",data.xPos, "\n","yPos : ",data.yPos, "\n", \
      "!\n", "!\n","!\n","!\n","!\n","!\n","!\n"


#------------- the same with additional string !!! not OK !!! --------------
#-- create
variable
containing
the
CDR
coded
TypeCode
CDROfTC_wString='\x01\x00\x00\x00\x0f\x00\x00\x00\x10\x01\x00\x00\x01+\x88w4\x00\x00\x00IDL:stringTest/stringInStruct/KomplexDatatype_t:1.0\x00\x12\x00\x00\x00KomplexDatatype_t\x00e\\\x05\x00\x00\x00\x03\x00\x00\x00pi\x00b\x06\x00\x00\x00\x05\x00\x00\x00data\x00ys\x08\x15\x00\x00\x00d\x00\x00\x00\x01\x00\x00\x001\x00\x00\x00IDL:stringTest/stringInStruct/DataSequence_t:1.0\x00ini\x0f\x00\x00\x00DataSequence_t\x00%\x13\x00\x00\x00\x0c\x00\x00\x00\x01\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00xPos\x00M\x1d\x01\x03\x00\x00\x00\x05\x00\x00\x00yPos\x00\x03\x00\x01\x03\x00\x00\x00\x05\x00\x00\x00name\x00\x01s\x02\x12\x00\x00\x00\x00\x00\x00\x00'
#-- create variable containing the CDR coded data
CDROfStruct_wString='\x01\x00\x00\x00\xc3\xf5H@\x18\x00\x00\x00A sequence of
characterso\x00\x00\x00+\x02\x00\x00\r\x00\x00\x00Pete Sampras\x00'

#-- cdrUnmarshal CDR coded contents
try:
  tc=omniORB.cdrUnmarshal(CORBA.TC_TypeCode, CDROfTC_wString)
  data=omniORB.cdrUnmarshal(tc, CDROfStruct_wString)  #-- crash!!
except:
    print "Error! -- omniORB.cdrUnmarshal"

print "!\n", "!\n","!\n","!\n","!\n","!\n","!\n", \
      "CDRDecoder found the following after cdrUnmarshal: \n", \
      "pi   : ",data.pi, "\n", "data : ",data.data, "\n", \
      "xPos : ",data.xPos, "\n","yPos : ",data.yPos, "\n", \
      "name : ",data.name, "\n", \
      "!\n", "!\n","!\n","!\n","!\n","!\n","!\n"


The IDL:

//-- KomplexDatatype_t.idl

module stringTest{
  interface stringInStruct{
  
    typedef sequence <octet> DataSequence_t;

    struct KomplexDatatype_t {
      float pi;
      DataSequence_t data;
      long xPos;
      long yPos;
      string name;
    };
      
    void setStruct(in KomplexDatatype_t complDT);
    KomplexDatatype_t getStruct();
    
  };
};


Contents of the sent struct (named data) to the client:

data.pi=3.14
data.data="A sequence of characters"
data.xPos=111
data.yPos=555
data.name="Pete Sampras"


Thanks in advance for any advise.

Frank









-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!