Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2007
solikhin solikhin is offline
Registered User
 
Name: solikhin solikhin
Organization: UII Yogyakarta
Project: Converting inhouse 2 tier to 3 tier architecture
 
Join Date: Jul 2007
Posts: 9
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
Reply With Quote
  #2 (permalink)  
Old 07-12-2007
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 931
It's impossible to help you without known what language you are using. Can you post the code that causes the problem? Also, if you look at language mapping chapter in the manual for your language, you should find the information you need there.

Cheers,

Michi.
Reply With Quote
  #3 (permalink)  
Old 07-13-2007
solikhin solikhin is offline
Registered User
 
Name: solikhin solikhin
Organization: UII Yogyakarta
Project: Converting inhouse 2 tier to 3 tier architecture
 
Join Date: Jul 2007
Posts: 9
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 ?.
Reply With Quote
  #4 (permalink)  
Old 07-13-2007
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,088
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.
Reply With Quote
  #5 (permalink)  
Old 07-13-2007
solikhin solikhin is offline
Registered User
 
Name: solikhin solikhin
Organization: UII Yogyakarta
Project: Converting inhouse 2 tier to 3 tier architecture
 
Join Date: Jul 2007
Posts: 9
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 ?.
Reply With Quote
  #6 (permalink)  
Old 07-13-2007
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,088
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);
};
then you could do something like:

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";
}
and

Code:
HelloPrx hello = ....;
Ice::StringSeq seq;
hello->sayHello(10, seq);
assert(seq.size() == 10);
Reply With Quote
  #7 (permalink)  
Old 07-13-2007
solikhin solikhin is offline
Registered User
 
Name: solikhin solikhin
Organization: UII Yogyakarta
Project: Converting inhouse 2 tier to 3 tier architecture
 
Join Date: Jul 2007
Posts: 9
Thanks a lot for your reply.
It clarifies something that I never realized before "out parameter send nothing to the server".
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -4. The time now is 12:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.