"Krzysztof Opała" <ko****@kszo.ostrowiec.pl> wrote in message news:<cg**********@druid.ceti.pl>...
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