By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,820 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,820 IT Pros & Developers. It's quick & easy.

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

P: n/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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"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
Jul 22 '05 #2

P: n/a
"Steve Vinoski" <vi*****@ieee.org> wrote in message
news:6c*************************@posting.google.co m...
"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


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
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.