[omniORB] Troubles with wstring
Giuseppe Naccarato
giuseppe.naccarato@picsel.com
Wed Nov 20 16:03:00 2002
Hi,
I defined the following idl:
interface Foo {
void startFoo(in wstring arg0 );
void startInt(in long arg0 );
};
Then I implemented a C++ Corba Server and compiled it with VC++ 6.0.
Here the server:
#include <iostream.h>
#include "Foo.hh"
// FooImpl
class FooImpl : public POA_Foo, public PortableServer::RefCountServantBase
{
public:
// Constructor
inline FooImpl() {}
// Destructor
virtual ~FooImpl() {}
// IDL Interface methods
virtual void startFoo(const CORBA::WChar* msg);
virtual void startInt(CORBA::Long n);
};
// IDL Interface dummy method implementations
void FooImpl::startFoo(const CORBA::WChar* msg){
cerr << "::startFoo() msg=" << msg << endl;
}
void FooImpl::startInt(CORBA::Long n){
cerr << "::startInt() n=" << n << endl;
}
static CORBA::Boolean bindObjectToName(CORBA::ORB_ptr, CORBA::Object_ptr);
int main(int argc, char **argv)
{
try {
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4");
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
FooImpl* foo = new FooImpl();
poa->activate_object(foo);
obj = foo->_this();
if( !bindObjectToName(orb, obj) )
return 1;
cerr << "FOO_OBJECT is now available!" << endl;
foo->_remove_ref();
PortableServer::POAManager_var pman = poa->the_POAManager();
pman->activate();
cerr << "[1]";
orb->run();
cerr << "[2]";
orb->destroy();
cerr << "[3]";
}
catch(CORBA::SystemException&) {
cerr << "Caught CORBA::SystemException." << endl;
}
catch(CORBA::Exception&) {
cerr << "Caught CORBA::Exception." << endl;
}
catch(omniORB::fatalException& fe) {
cerr << "Caught omniORB::fatalException:" << endl;
cerr << " file: " << fe.file() << endl;
cerr << " line: " << fe.line() << endl;
cerr << " mesg: " << fe.errmsg() << endl;
}
catch(...) {
cerr << "Caught unknown exception." << endl;
}
return 0;
}
etc...
I also developed a Java client using the JDK 1.4 and JavaIDL.
When the client calls the startInt method, everything works fine.
Instead, if startFoo is called (with a java string as parameter) the
server properly executes the method but then it crashes showing a
windows dialog: _BLOCK_TYPE_IS_VALID.
I suppose there's something wrong with the wstring.... but what?
Thanks
joe