[omniORB] omniORBpy & omniORB (C++) Questions

Wilson Jimmy - jiwils Jimmy.Wilson@acxiom.com
Thu, 24 May 2001 16:20:16 -0500


I have the following two clients.  One of them is written for use in
conjunction with omniORBpy the other is written for use in conjunction with
omniORB.  The server prints the method name (in addition other things) so I
can see each call as it is made.  The stub code for each client was created
with the same IDL.  Each of the clients correctly communicates with the
remote object (the same in both cases), but the call to Release with the
omniORB (C++) client throws a system exception with a minor code of 0.  Is
there a glaring problem with the C++ client below?  If not, is there a
direction that someone can point me in?  Thanks for your help!

=====Begin Python Client=====
import string
import sys
import omniORB
import CORBA
import ErrorService

GenericURI =
"corbaloc:iiop:%host%:1570/:%5c%host%:ErrorServer:0::IFR:ErrorService_ErrorS
erviceFactory%00"

# get input parameters
CORBAHostName = raw_input("Enter the host name of the error service: ")

# get an error service factory object reference
ORB = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
IOR = ORB.string_to_object(string.replace(GenericURI, "%host%",
CORBAHostName))

try:
	ErrorServiceFactory = IOR._narrow(ErrorService.ErrorServiceFactory)
	SnapinErrorDataObj = ErrorServiceFactory.Create("SnapinErrorData")
	SnapinErrorData =
SnapinErrorDataObj._narrow(ErrorService.SnapinErrorData)
	SnapinErrorData.Release()

except:
	print "Error using the ErrorServiceFactory object."
	ORB.destroy()
	sys.exit(1)

ORB.destroy()
=====End Python Client=====

=====Begin C++ Client=====
#include <iostream>
#include "ErrorService.hh"

short main(int argc, char** argv)
{
	const char* pszURI =
"corbaloc:iiop:acxser3:1570/:%5cacxser3:ErrorServer:0::IFR:ErrorService_Erro
rServiceFactory%00";

	CORBA::ORB_var pvORB = CORBA::ORB_init(argc, argv, "omniORB3");
	
	// Create CORBA object reference.
	CORBA::Object_var pvObject = pvORB->string_to_object(pszURI);

	ErrorService::ErrorServiceFactory_var pvESFactory;

	// Connect to the object reference.
	try
	{
		pvESFactory =
ErrorService::ErrorServiceFactory::_narrow(pvObject);

		if (CORBA::is_nil(pvESFactory))
		{
			std::cout << "Can't narrow reference to type
ErrorServiceFactory (or it was nil)."  << std::endl;
		}

		// Create a snapin error data interface.
		CORBA::String_var svInterfaceName = (const char*)
"SnapinErrorData";

		CORBA::Object_var pvGenericObject =
pvESFactory->Create(svInterfaceName);
		ErrorService::SnapinErrorData_var pvSnapinErrorData =
ErrorService::SnapinErrorData::_narrow(pvGenericObject);

		// Destroy the snapin error data interface.
		pvSnapinErrorData->Release(); // Throws a system exception.

		// Destroy the ORB.
		pvORB->destroy();	
	}
	catch (CORBA::COMM_FAILURE& exCommFailureException)
	{
		std::cout << "Communication failure.  Unable to contact the
remote object."  << std::endl;
	}
	catch (CORBA::SystemException& exSystemException)
	{
		std::cout << "System Exception: " <<
exSystemException.minor() << std::endl;
	}

	return 0;
}
=====End C++ Client=====

Jimmy
-- 
James "Jimmy" Wilson
Software Developer, Acxiom Corporation
Solvitur4 Online Customer Data Integration Architecture, F012-21 (#2150)
1001 Technology Drive, Little Rock, AR  72223
Phone: 501.342.4102  Fax: 501.342.4902  E-Mail: jiwils@acxiom.com