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

techy_bolek techy_bolek at yahoo.com
Mon Nov 30 09:51:31 GMT 2009


Ok, my bad, your C++ code actually does show a piece of a CORBA client code.
First, you should know that CORBA is a platform-independent technology. This
means your client does not care what whether your server is Java, C++ or
whatever - as long as they two speak CORBA they can talk to each other
through CORBA.
That being said, what you need is a CORBA C++ client, assuming that you have
your CORBA server correctly implemented. Have you tested your server with
other clients yet?
You should be able to find an example in any CORBA tutorial. You got the
initial steps handled, whereby you set the ORB parameters and connect to the
remote object. I have not validated your code that thoroughly but it looks
good at a first glance.





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-tp26542605p26578926.html
Sent from the OmniORB - User mailing list archive at Nabble.com.




More information about the omniORB-list mailing list