Problem when converting IOR to object reference



Hi all,

Hope someone can help me with this newbie question/problem.

I'm using Orbit2 when implementing an API that misc applications can use to invoke operations on a server application running on another machine in a LAN. Client platform is Linux RedHat 8. Server platform is Windows 2000 and Suns Java ORB JDK1.4.2. I'm getting an IOR via a normal socket connection with the server and then I try to convert it to an object reference by using CORBA_ORB_string_to_object() but end up with the exception IDL:omg.org/CORBA/MARSHAL:1.0 instead. I'm having problem figuring out the cause of this problem. My IOR is retrieved successfully. The ORB seem to initialize ok. I know I have to enable remote invocations since they are disabled by default so I placed the following lines in /etc/orbitrc as suggested in the beginners documentation:

ORBIIOPUSOCK=1
ORBIIOPIPv4=1
ORBIIOPIPv6=0 

Here some code that shows what I'm doing:

adapter.h
=========

// Return value constants
#define SUCCESS 0
#define SYSTEM_EXCEPTION 1
#define SERVER_EXCEPTION 2
#define LOGON_EXCEPTION 3
#define SEARCH_EXCEPTION 4
#define FLEX_EXCEPTION 5
#define TIMEOUT_EXCEPTION 6

/** 
 * Function used to initialize the adapter and logon to the server
 * On success the return value is SUCCESS.
 * On failure the return value is one of the following values:
 * SERVER_EXCEPTION = failed to get a reference to the adapterserver
 * LOGON_EXCEPTION = the logon failed. 
 */
int flexadapter_init(char *host, char *username, char *password);



adapter.c
=========

#include <assert.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <orbit/orbit.h>

#include "adapter.h"
#include "AdapterServer.h"
#include "referenceutil.h"

static CORBA_ORB orb = CORBA_OBJECT_NIL;
static CORBA_Environment env;
static CORBA_char *session_key;
static appl_adapterinterface_proxy_AdapterServer adapterserver = CORBA_OBJECT_NIL;

int adapter_init(char *host, char *username, char *password) {
  // Declare the std arguments
  int argc = 1;
  char *argv[1];
  CORBA_char *objref = NULL;
  CORBA_Object obj = CORBA_OBJECT_NIL;

  // Initialize exception handling
  CORBA_exception_init(&env);

  // Initialize ORB
  orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &env);
  if (env._major != CORBA_NO_EXCEPTION) {
    g_error(CORBA_exception_id (&env));                        
    CORBA_exception_free (&env);                                
    return SYSTEM_EXCEPTION;
  }
  
  // Getting IOR
  #ifdef _DEBUG
  g_print ("Reading service reference from socket\n");
  #endif

  if (getReference(host, &objref) != 0) {
    g_print("Failed to get object reference\n");
    return SYSTEM_EXCEPTION;
  }
  
  // Convert IOR to object reference
  #ifdef _DEBUG
  g_print ("Convert IOR to object. IOR is %s\n", objref);
  #endif

  // This is where I run into problem and get exception IDL:omg.org/CORBA/MARSHAL:1.0 
  obj = (CORBA_Object)CORBA_ORB_string_to_object (orb, objref, &env);
  if (env._major != CORBA_NO_EXCEPTION) {    
    g_error(CORBA_exception_id (&env));                        
    CORBA_exception_free (&env);                                
    return SYSTEM_EXCEPTION;
  }

  free(objref);

  #ifdef _DEBUG
  g_print("Cast object to adapterserver\n");
  #endif

  adapterserver = (appl_adapterinterface_proxy_AdapterServer)obj;   
  
  // Logon to adapter server
  #ifdef _DEBUG
  g_print ("Logon on to FLEX\n");
  #endif

  session_key = appl_adapterinterface_proxy_AdapterServer_logon(adapterserver, username, password, &env); 
  if (env._major == CORBA_SYSTEM_EXCEPTION) {    
    g_error(CORBA_exception_id (&env));                        
    CORBA_exception_free (&env);                                
    return SYSTEM_EXCEPTION;
    
  } else if (env._major == CORBA_USER_EXCEPTION && \
	     !strncmp (ex_appl_adapterinterface_except_C_LogonException, \
		       CORBA_exception_id (&env), strlen (ex_appl_adapterinterface_except_C_LogonException))) {  
    g_error(CORBA_exception_id (&env));                        
    CORBA_exception_free (&env);                                
    return LOGON_EXCEPTION;  
  } 
  
  #ifdef _DEBUG
  g_print ("Session key is %s \n", session_key);
  #endif

  return SUCCESS;
}



I build my lib (shared object) using the following makefile:

PREFIX ?= /usr
CC = gcc
TARGETS=lib
ORBIT_IDL=$(PREFIX)/bin/orbit-idl-2
CFLAGS=-O -Wall -fpic -DORBIT2=1 -D_REENTRANT -I$(PREFIX)/include/orbit-2.0 \
       -I$(PREFIX)/include/linc-1.0 -I$(PREFIX)/include/glib-2.0 \
       -I$(PREFIX)/lib/glib-2.0/include -g -D_DEBUG
LDFLAGS= -Wl,--export-dynamic -L$(PREFIX)/lib -lORBit-2 -llinc -lgmodule-2.0 \
             -ldl -lgobject-2.0 -lgthread-2.0 -lpthread -lglib-2.0 -lm       \
             -lORBitCosNaming-2

IDLOUT=AdapterServer-common.c AdapterServer-stubs.c AdapterServer.h

all: $(IDLOUT) api lib

api: adapter.o referenceutil.o AdapterServer-stubs.o AdapterServer-common.o

$(IDLOUT): AdapterServer.idl
	$(ORBIT_IDL) --noskels  AdapterServer.idl

lib: api
	$(CC) -o libadapter.so -shared flexadapter.o referenceutil.o AdapterServer-common.o \
                 AdapterServer-stubs.o $(LDFLAGS)

clean:
	rm -rf *.o *~ $(IDLOUT)

distclean: clean
	rm -rf libadapter.so



What am I doing wrong? Any suggestions on how I should approach this problem?

Thanks in advance

Regards

/Johan

-------------------------------------------------
Johan Antonsson        johan.antonsson@ibitec.se
-------------------------------------------------





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]