IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

CORBA Discussion :

[Débutant] Problème lors de _narrow


Sujet :

CORBA

  1. #1
    Membre averti
    Inscrit en
    Juin 2006
    Messages
    570
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 570
    Points : 340
    Points
    340
    Par défaut [Débutant] Problème lors de _narrow
    Bonjour,
    j'ai un problème lors de l'appelle à la fonction _narrow(CORBA::Object_var)

    voici tout d'abord mon fichier idl :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    module relais {
    
      interface RelaisCorba {
    
      	   string creerCertificat( in string req );
    	   string recupererCertificat();
      };
    };

    Voici ensuite la partie cliente :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    try {
            // Initialize ORB
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4");
     
        //
        // Get naming service
        //
        CORBA::Object_var obj;
    
        try {
          obj = orb -> resolve_initial_references("NameService");
        }
        catch(const CORBA::ORB::InvalidName&) {
          cerr << argv[0] << ": can't resolve `NameService'" << endl;
        }
        
        if(CORBA::is_nil(obj)) {
          cerr << argv[0] << ": `NameService' is a nil object reference" << endl;
        }
        
        CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow(obj);
    
        CORBA::Object_var objCommunication;
        try {
    
          //
          // Compose Name and get reference
          //
          CosNaming::Name ncName;
          ncName.length(1);
          
          ncName[0].id = CORBA::string_dup("relais");
          ncName[0].kind = CORBA::string_dup("");
    
          objCommunication = nc -> resolve(ncName);
    
        } catch (const CORBA::Exception& ex) {
    
          cerr << "Erreur rebind" << endl;
        }
    
        if(CORBA::is_nil(objCommunication)) {
    cout<<"objCommunication is nil;
    }  	    
        //Echo_ptr echoref = Echo::_narrow(objCommunication);
        relais :: RelaisCorba_ptr echoref = relais::RelaisCorba::_narrow(objCommunication);
        if( CORBA::is_nil(echoref) ) {
          cerr << "Can't narrow reference to type Echo (or it was nil)." << endl;
          return 1;
        }
    
        // invoc server
        
        CORBA::String_var dest = echoref->creerCertificat(message);
        
        cout << "I said, \"" << message << "\"." << endl
    	 << "The Relais object replied, \"" << (char*)dest <<"\"." << endl;
        
        // shutdown orb 
        orb->destroy();
      }
      catch(CORBA::UserException& e) {
        cerr << "Caught CORBA::UserException." << endl;
        cout << e._name();
      
      }
      catch(CORBA::SystemException& e) {
        cerr << "Caught CORBA::SystemException." << endl;
        cout << e._name();
      
      }
    Donc, sur la ligne
    relais :: RelaisCorba_ptr echoref = relais::RelaisCorba::_narrow(objCommunication); (en rouge dans le code) j'ai un retour null.

    Le rebind s'effectue pourtant bien juste avant, donc je suppose que le problème ne vient pas du registry ou du serveur, non ? Sachant que ce serveur est en java.
    Voyze vous d'ou peut venir le problème ?

  2. #2
    Membre averti
    Homme Profil pro
    Architecte technique
    Inscrit en
    Septembre 2006
    Messages
    219
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2006
    Messages : 219
    Points : 302
    Points
    302
    Par défaut
    Bonjour,

    Si objCommunication est non nil et que relais::RelaisCorba::_narrow(objCommunication) retourne nil, c'est que objCommunication n'est pas du type relais::RelaisCorba.

Discussions similaires

  1. [Débutant] Problème d'import lors du développement d'un plug-in
    Par adel25 dans le forum Eclipse Platform
    Réponses: 2
    Dernier message: 19/05/2015, 12h08
  2. Réponses: 1
    Dernier message: 10/07/2007, 07h25
  3. Réponses: 5
    Dernier message: 04/07/2006, 16h05
  4. Réponses: 7
    Dernier message: 27/09/2005, 21h40
  5. Réponses: 2
    Dernier message: 17/08/2003, 20h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo