[omniORB] How to connect and call C++/Qt client and Java Server

techy_bolek techy_bolek at yahoo.com
Sun Nov 29 23:02:18 GMT 2009


I've no idea what are you trying to do. Firstly, you say you want to connect
a C++ client to Java server but you throw a C++ server code. Secondly, my
assumption was that the you were using CORBA but I see a J2EE 3.0 session
bean in your Java code.




Juaci Monteiro de Carvalho-2 wrote:
> 
>     Hi all,
>     I'm programming in C++/Qt. Today I intend to use C++/Qt just to 
> client and Java to server using glassfish and DB PostgreSQL.
>     This example(1) in java (client and server), it's working.  
>     I'm searching a solution to mix this two technologies(C++/Qt and 
> Java server).
>     I did a bean class to return a little message(java)
> 
>     Ex 1: server
> 
> package br.com.cadastro;
> 
> import java.util.List;
> import javax.ejb.Stateless;
> 
> /**
>  *
>  * @author juaci
>  */
> @Stateless
> public class CadastroBean implements CadastroRemote, CadastroLocal {
> 
>     public String getName() {
>         return "<<<<<<<<<<    My first test..... >>>>>>>>>>>>>>>>";
>     }
> }
> 
> 
> Ex 2: client C++/Qt
> 
> 1 - How can I pass the parameter using this command line to test this 
> code below?
>     Command line:   ./cliente corbaname:iiop:localhost:3700/NameService
> 
> 2 - The name of package in java  is  "br.com.cadastro.CadastroRemote".
>       I would like adjust the command line above calling my package and 
> to fix this piece of code below.
> 
>         CosNaming::Name name;
>         name.length(1);
>         name[0].id = CORBA::string_dup("CadastroRemote");
>         // name[0].id =
> CORBA::string_dup("br.com.cadastro.CadastroRemote");
>         name[0].kind = CORBA::string_dup("");
> 
> 
> #include "CadastroRemote.h"
> #include <iostream>
> #include <CORBA.h>
> #include <Naming.hh>
> using namespace std;
> int main(int argc, char ** argv)
> {
> try {
>     // init ORB
>     CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
>     // resolve service
>     CadastroRemote_ptr cadastro = 0;
>     try {
>         CORBA::Object_var ns_obj = 
> orb->resolve_initial_references("NameService");
>         if (!CORBA::is_nil(ns_obj)) {
>         CosNaming::NamingContext_ptr nc = 
> CosNaming::NamingContext::_narrow(ns_obj);
>         CosNaming::Name name;
>         name.length(1);
>         name[0].id = CORBA::string_dup("CadastroRemote");
>         // name[0].id = 
> CORBA::string_dup("br.com.estante.cadastro.CadastroRemote");
>         name[0].kind = CORBA::string_dup("");
>         CORBA::Object_ptr obj = nc->resolve(name);
>         if (!CORBA::is_nil(obj)) {
>             cadastro = CadastroRemote::_narrow(obj);
>         }
>     }
>     } catch (CosNaming::NamingContext::NotFound &) {
>         cerr << "not found" << endl;
>     } catch (CosNaming::NamingContext::InvalidName &) {
>         cerr << "invalid name" << endl;
>     } catch (CosNaming::NamingContext::CannotProceed &) {
>         cerr << "cannot proceed" << endl;
>     }
> 
>     if (!CORBA::is_nil(cadastro)) {
>         char * server = cadastro->getNome();
>         cout << "answer from: " << server << endl;
>         CORBA::string_free(server);
>     }
> 
>     // destroy ORB
>     orb->destroy();
>     } catch (CORBA::UNKNOWN) {}
> }
> 
> // EOF
> 
> 
> 
>     If I made a mistake with codes please correct me.
>     Someone has another better idea I appreciate your help.
>     Thanks.
> 
> __________________________________________________
> Faça ligações para outros computadores com o novo Yahoo! Messenger 
> http://br.beta.messenger.yahoo.com/ 
> 
> 
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-connect-and-call-C%2B%2B-Qt-client-and-Java-Server-tp26542605p26562807.html
Sent from the OmniORB - User mailing list archive at Nabble.com.




More information about the omniORB-list mailing list