[omniORB] Problem with: Dynamic Invocation Interface

Finn B. Laustsen fbl@transynergy.net
Tue, 26 Feb 2002 11:06:11 +0100


Hi, 

I have a problem with Dynamic Invocation Interface.

It works fine with the basic types like 'tk_boolean' - but I have problems
with other types like sequences and interface.

I quess that the problem lies in setting the return type with the correct
typecode!

Can anybody help me out... (see Code+ IDL below)


Thanks

Finn

---------------
The code:

	CORBA::ORB_ptr orb_ptr;
	CORBA::Object_var domObj;
	char ior[] = "corbaname::/NameService#RunTime/Transynergy/Dom_impl";
	int argc = 0;

	orb_ptr = CORBA :: ORB_init( argc, NULL, "omniORB3" );
	domObj = orb_ptr->string_to_object( ior);
	dom::Node_var ref = dom::Node::_narrow(domObj);

	bool yes1 = ref->hasChildNodes();		// works fine - not
DII
	dom::DOMString_var navn = ref->nodeName();	// works fine - not
DII
	dom::Node_ptr xx1 = ref->firstChild();		// works fine - not
DII
	
	try {
		char callMethod[] = "hasChildNodes";
		CORBA::Request_var req = domObj->_request( callMethod );
		// set return type
		req->set_return_type(CORBA::_tc_boolean);

		req->invoke();			// Works fine

		CORBA::Exception* excep = req->env()->exception();
		if( excep ) {
			std::string exceptionText("Unable to invoke CORBA
object: Dom_impl, , callMethod:");
			exceptionText += callMethod;
			throw exception( exceptionText.c_str());
		}
	} catch (...) {
		throw "request 1 failed";
	}

	try {
		char callMethod[] = "nodeName";
		CORBA::Request_var req = domObj->_request( callMethod );
		// set return type
		CORBA::TypeCode_ptr tc_dom_DOMString =
CORBA::TypeCode::PR_alias_tc("IDL:dom/DOMString:1.0", "DOMString",
CORBA::TypeCode::PR_sequence_tc(0, CORBA::TypeCode::PR_ushort_tc()));
		req->set_return_type(tc_dom_DOMString);

		req->invoke();			// **** Request fails ****
(throw BAD_OPERATION from poa.cc:1334)

		CORBA::Exception* excep = req->env()->exception();
		if( excep ) {
			std::string exceptionText("Unable to invoke CORBA
object: Dom_impl, , callMethod:");
			exceptionText += callMethod;
			throw exception( exceptionText.c_str());
		}
	} catch (...) {
		throw "request 2 failed";
	}

	try {
		char callMethod[] = "firstChild";
		CORBA::Request_var req = domObj->_request( callMethod );
		// set return type
		CORBA::TypeCode_ptr my_tc_Node =
CORBA::TypeCode::PR_interface_tc("IDL:dom/Node:1.0", "Node");
		req->set_return_type(my_tc_Node);

		req->invoke();			// **** Request fails ****
(throw BAD_OPERATION from poa.cc:1334)

		CORBA::Exception* excep = req->env()->exception();
		if( excep ) {
			std::string exceptionText("Unable to invoke CORBA
object: Dom_impl, , callMethod:");
			exceptionText += callMethod;
			throw exception( exceptionText.c_str());
		}
	} catch (...) {
		throw "request 3 failed";
	}

The IDL (for test purpose):

module dom
{
  typedef sequence<unsigned short> DOMString;

  exception DOMException {
    unsigned short   code;
  };

  interface Node {
	readonly attribute DOMString       nodeName;

    readonly attribute Node            firstChild;
    boolean            hasChildNodes();
  };

  interface Element : Node {
  };

  interface Document : Node {
    readonly attribute Element         documentElement;
    Element            createElement(in DOMString tagName)
                                        raises(DOMException);
  };
};