|
|
|
|||||
|
out parameter with non basic type
Hello,
I'm new to ice. I have problem (run time error on the server) with the use of out parameter with non basic data type. This one is work fine : interface Hello { void sayHello(out string); // out parameter with basic data type }; but this is not : interface Hello { void sayHello(out SequenceOfSomething); // out parameter with non basic data type }; Is there any special treatment for out parameter with non basic type ?. I've tried to search this on the demo sample but can't find it. Thanks in advance for your help, regards, solikhin |
|
|||||
|
Thanks for your quick reply,
I'm using C++. Unintentionally, I seem to have solved the problem. Calling the servant with uninitialized variables seem to solve the problem (actually I'm not 100% sure because I'm a newbie, but in my case the problem disappear and I get the expected result / value). Here is the original client code : SequenceOfSomething tmpSomething(someSize); // I determined the size here ObjProxy->sayHello(tmpSomething); Here is the modified client code : SequenceOfSomething tmpSomething; // I remove the size here ObjProxy->sayHello(tmpSomething); Is this the correct way on doing this thing ?. |
|
||||||
|
I tried to duplicate this problem with the hello world demo (demo/Ice/hello) and could not reproduce it. I don't think this can be the reason for the initial failure, you must have had some other issue.
|
|
|||||
|
Actually I just use Hello to ilustrate my problem. My actual code has return value of type sequence, several in parameter of type sequence, and 1 out parameter of type sequence.
Basically, what I have done in trying to solve this problem is just remove the size as ilustrated above (in the client side). In the server side, I made litle change in the way out parameter is processed : Original server side code : void Demo::sayHello(Demo::SequenceOfSomeThing xyz) { xyz[0].member1 = ....; // I originally have determined the size of this variable xyz[0].member2 = ....; // from client side, and here I just assign the value xyz[0].member3 = ....; }; Modified server side code : void Demo::sayHello(Demo::SequenceOfSomeThing xyz) { SequenceOfSomeThing tmpData(SomeSize); tmpData[0].member1 = ....; tmpData[0].member2 = ....; tmpData[0].member3 = ....; xyz = tmpData; }; That's all I've done in the client side and the server side. Or, Maybe I just been unlucky by hitting / exceeding maximum message size in first run of my program ?. Any idea ?. |
|
||||||
|
It looks to me like you expect the client to send the expected size of the out field to the server. This is not the case -- out parameters send nothing to the server (that is value that is passed to the servant is uninitialized). if you want to send an expected size then you must pass this as an additional parameter.
Code:
interface Hello
{
void sayHello(int sz, out Ice::StringSeq seq);
};
Code:
void HelloI::sayHello(int sz, Ice::StringSeq& seq, const Ice::Current&)
{
seq.size(sz);
for(int i = 0; i < sz; ++i) seq[i] = "hello world";
}
Code:
HelloPrx hello = ....; Ice::StringSeq seq; hello->sayHello(10, seq); assert(seq.size() == 10); |
|
|||||
|
Thanks a lot for your reply.
It clarifies something that I never realized before "out parameter send nothing to the server". |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ip Addresses and basic conection questions | EmmanuelOga | Help Center | 5 | 07-31-2006 06:45 PM |
| Visual Basic two-way communication with Java | msciarra | Help Center | 3 | 12-01-2004 03:33 PM |
| vector as out parameter | Dmitriy | Help Center | 10 | 06-29-2004 04:39 AM |
| about out parameter | simpley | Help Center | 3 | 03-18-2004 04:45 PM |
| basic freeze problem | salva | Help Center | 1 | 06-30-2003 07:14 PM |