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

techy_bolek techy_bolek at yahoo.com
Wed Dec 2 15:44:35 GMT 2009


Not sure if my previous message was accepted so here it is again.
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:
> 
> Ok, thanks for your help.
> I'm beginner, I was thinking that code (Corba) would be to use for client.
> It's possible you send me an example C++ Corba for client and using 
> javaEE5 (server)?
> This I'm trying to do.
> 
> 
> 
>> 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
>>>
>>>
>>>     
>>
>>   
> 
> __________________________________________________
> 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-tp26542605p26618696.html
Sent from the OmniORB - User mailing list archive at Nabble.com.




More information about the omniORB-list mailing list