Home Help Center

sth wrong with the client written in Python and Server written in C++

hardawayhardaway Member hardawaycOrganization: testProject: test
simply to say:
slice code on server side:
interface IAddress
{
TEnterpriseInfo getEnterpriseInfo(string telno)
}
class TEnterpriseInfo
{
string name;
string code;
}
client code:
addrPrx = IAddressPrx.checkedCast(proxy)
if not addrPrx:
print args[0] + ": invalid proxy"
return 1
print "start..."
try:
a = addrPrx.getEnterpriseInfo("111")
print a.name
except:
traceback.print_exc()

the server side was written by C++ and works well.and someone else wrote a simple client to test the server in C++ ,also works well

and now i wrote a client in Python,it throws such Exception:
================================================
start...
Traceback (most recent call last):
File "testAddr.py", line 27, in run
a = addrPrx.getEnterpriseInfo("111")
File "IAddress.ice", line 1460, in getEnterpriseInfo
UnmarshalOutOfBoundsException: exception ::Ice::UnmarshalOutOfBoundsException
{
reason =
}
================================================
why??who knows..pls help me figure out the problem.thx a lot

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Hi,

    I tried writing a python client and C++ server using your interface definition and had no issues. This was with Ice 2.1.1. Perhaps you could supply a more complete code example that duplicates the problem you are seeing. Also, please indicate the version of Ice and Python you are using as well as the operating system.

    Regards,
    Dwayne
  • hardawayhardaway Member hardawaycOrganization: testProject: test
    k,now i got the answer,it's my fault~~
    actuall i defined them in two files,IAddress.ice,IAddressData.ice
    code in IAddress.ice
    *****************************
    #include <IAddressData.ice>
    interface IAddress
    {
    TEnterpriseInfo getEnterpriseInfo(string telno)
    }
    *****************************
    and code in IAddressData.ice
    *****************************
    class TEnterpriseInfo
    {
    string name;
    string code;
    }
    *****************************
    and in the testAddr.py file,i wrote code like this:
    *****************************
    Ice.loadSlice("--all -I../slice -I/Ice/slice ../slice/IAddressData.ice")
    Ice.loadSlice("--all -I../slice -I/Ice/slice ../slice/IAddress.ice")
    *****************************

    --all is the cause,if i remove
    Ice.loadSlice("--all -I../slice -I/Ice/slice ../slice/IAddressData.ice")
    this line,and then the client works well
    and also if i only remove --all ,it works well too


    btw.Ice version:2.1.1,Python Version 2.4 Os:linux

    Dwayne: thx a lot. u guys r so great!!!
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Hi,

    Actually, it was not your fault. :)
    hardaway wrote:
    Ice.loadSlice("--all -I../slice -I/Ice/slice ../slice/IAddressData.ice")
    Ice.loadSlice("--all -I../slice -I/Ice/slice ../slice/IAddress.ice")

    The fact that this caused an unmarshal exception was a bug in Ice. Although loading both slice files with --all is unnecessary since IAddress.ice includes IAddressData.ice, it should not cause an exception. A fix will be available in the next Ice release.

    Thanks for the report,
    Dwayne
  • hardawayhardaway Member hardawaycOrganization: testProject: test
    hi dwayne..still the same problem

    now the problem is that i got a application that include two service
    like this:
    i'll simply write the code
    service A: two.ice files
    a.ice:
    #incldue <aData.ice>
    interface atest
    {
    aSeq returnaSeq()
    }
    throws CommonException
    aData.ice:
    #include <common.ice>
    struct aSeq
    {
    ...
    }
    service B : 2 .ice file
    b.ice:
    #incldue <bData.ice>
    interface btest
    {
    bSeq returnbSeq()
    }
    throws CommonException
    bData.ice:
    #include <common.ice>
    struct bSeq
    {
    ...
    }
    common.ice the public file which inclueded both in aData.ice and bData.ice
    exception CommonException
    {

    }
    and now here if i have an application that both includes these two serivce.i mean include a.cie and b.ice
    i write code like this:
    Ice.loadSlice(" -all -I./ a.ice")
    Ice.loadSlice(" -all -I./ b.ice")
    it throws RuntimeError: Slice parsing failed for a.ice
    i thought the problem is that both the two files include common.ice
    can u tell me how to solve this problem?

    best regards
    hardaway
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    There are a number of syntax errors in the sample Slice code you posted. In order for us to help you we would need the exact Slice code you are trying to use. Can you put them in a ZIP file and attach them to a message?

    Thanks,
    - Mark
Sign In or Register to comment.