[omniORB] Problems trying to user the Trader service

Sonal Agrawal soagrawa@genuity.com
Tue, 4 Sep 2001 17:26:04 -0400


Hello,

I am trying to use the Trader service to get certain Factory agent objects.
I do get a valid traderLookupPtr however, I get an invalid ptr returned from
CosTrading::Lookup::_narrow(traderLookupRef) when I narrow it.  Hence, I get
an exception later when I do a traderLookupPtr->query(....).

I am attaching the snipet of code below.  The traderLookupPtr is defined as:
CosTrading::Lookup_ptr traderLookupPtr;  in the header file.  I am able to
succesfully execute a sample client written with Orbix by the vendor but not
this code using OmniOrb.   Do I need to set omniORB in a certain way?
Please could someone help.

Thanks,

Sonal Agrawal



  const char *traderIorPathname = "./TRADER_IOR";
  FILE *traderIorFileHandle;
  CORBA::String_var traderIor = CORBA::string_alloc(2048);
  CORBA::Object_ptr traderLookupRef = 0;

  cout << "Getting 'TradingService' reference...";

  // Read the file to get the trader IOR
  traderIorFileHandle=fopen(traderIorPathname, "r");
  fgets(traderIor,2048, traderIorFileHandle);
  fclose(traderIorFileHandle);

  traderLookupRef = orb->string_to_object(traderIor);
  if (CORBA::is_nil(traderLookupRef))
  {
    cout << "failed to get trader Ref!" << endl;
        exit(-1);
  }
  else
  {
    traderLookupPtr = CosTrading::Lookup::_narrow(traderLookupRef);
    cout << "done!" << endl;
  }


 if (CORBA::is_nil(traderLookupPtr))
  {
    cout << "failed to get trader Ptr!" << endl;
        exit(-1);   // ************ programs exits here
  }
  else
  {
    cout << "done!  Ready to use the Trader" << endl;
  }