[CORBA, Visibroker, C++] Array, sequence problem.

K

Krzysztof Opa³a

Hi
I've got my CORBA application written in Borland C++ Builder, using
Visibroker. What I wanna do is get from server a set of strings (the number
of string is not constant). I was trying to do it with sequence but got some
problems. Here is the method i IDL:

long get_clerks_list (out workerseq loginnames);

where long is number of strings in loginnames
and
typedef sequence<long> workerseq;

Could anybody give me a simple example how to write a server function
(puting 'aaa', 'bbb', 'ccc' and returning it), and how to use it by client.
I'll compare it to my code and find out what's wrong.

Thanks in advance
Chris
 
S

Steve Vinoski

Krzysztof Opa³a said:
I've got my CORBA application written in Borland C++ Builder, using
Visibroker. What I wanna do is get from server a set of strings (the number
of string is not constant). I was trying to do it with sequence but got some
problems. Here is the method i IDL:

long get_clerks_list (out workerseq loginnames);

where long is number of strings in loginnames
and
typedef sequence<long> workerseq;

Could anybody give me a simple example how to write a server function
(puting 'aaa', 'bbb', 'ccc' and returning it), and how to use it by client.
I'll compare it to my code and find out what's wrong.

I assume workerseq is a sequence of string, not a sequence of long.

CORBA::Long
YourServantClass::get_clerks_list(workerseq_out loginnames)
throw(CORBA::SystemException) {
workerseq_var ws = new workerseq(3);
ws->length(3);
ws[0] = CORBA::string_dup("aaa");
ws[1] = CORBA::string_dup("bbb");
ws[2] = CORBA::string_dup("ccc");
loginnames = ws._retn();
return loginnames->length();
}

Assuming the client already has an object reference to your object, it
does something like this:

workerseq_var ws;
CORBA::Long len = objref->get_clerks_list(ws.out());
cout << "first entry is " << ws[0] << endl;

See "Advanced CORBA Programming with C++" for more details
(http://www.iona.com/hyplan/vinoski/).

--steve
 
K

Krzysztof Opala

Steve Vinoski said:
"Krzysztof Opa³a" <[email protected]> wrote in message
I've got my CORBA application written in Borland C++ Builder, using
Visibroker. What I wanna do is get from server a set of strings (the number
of string is not constant). I was trying to do it with sequence but got some
problems. Here is the method i IDL:

long get_clerks_list (out workerseq loginnames);

where long is number of strings in loginnames
and
typedef sequence<long> workerseq;

Could anybody give me a simple example how to write a server function
(puting 'aaa', 'bbb', 'ccc' and returning it), and how to use it by client.
I'll compare it to my code and find out what's wrong.

I assume workerseq is a sequence of string, not a sequence of long.

CORBA::Long
YourServantClass::get_clerks_list(workerseq_out loginnames)
throw(CORBA::SystemException) {
workerseq_var ws = new workerseq(3);
ws->length(3);
ws[0] = CORBA::string_dup("aaa");
ws[1] = CORBA::string_dup("bbb");
ws[2] = CORBA::string_dup("ccc");
loginnames = ws._retn();
return loginnames->length();
}

Assuming the client already has an object reference to your object, it
does something like this:

workerseq_var ws;
CORBA::Long len = objref->get_clerks_list(ws.out());
cout << "first entry is " << ws[0] << endl;

See "Advanced CORBA Programming with C++" for more details
(http://www.iona.com/hyplan/vinoski/).

--steve

Thanks a lot for your answer. It's going to be better but I still got one
big problem. While calling my method from client - the client throw
"External exception EEFFACE". What is strange - I call other methods from
the same interface and they're doing well. Have you got any idea ?

BTW: Of course workerseq is a sequence of string :)

Regards
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top