Byte array question
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Jul 14 05:26:00 EDT 2006
In <1152817088.549439.201960 at b28g2000cwb.googlegroups.com>, Dan Winsor
wrote:
> Sybren Stuvel wrote:
>> dan.winsor at gmail.com enlightened us with:
>> > I want to send thorugh the API. However, no matter how I try it,
>> > Java on the other end doesn't like what I'm passing it there.
>>
>> What have you tried and how did it fail?
>
> See below.
>
>> > How can I mimic a byte array in python?
>>
>> Strings?
>
> OK, I'll put that attempt up front. Here's a couple of tries:
>
> <test code snippet>
> fileobj = open('testfile.txt', mode='r')
> chararray = fileobj.read()
> fileobj.close()
>
> soap.addAttachmentsToIssue(auth,'TST-4','testfile.txt',chararray)
>
> <fails with>
> SOAPpy.Types.faultType: <Fault soapenv:Server.userException:
> org.xml.sax.SAXException: Found character data inside an array element
> while deserializing: <SOAPpy.Types.structType detail at -1216265236>:
> {'hostname': '<removed>', 'faultData': <SOAPpy.Types.structType
> faultData at -1216226708>: {'exception': None, 'message': 'Found
> character data inside an array element while deserializing'}}>
In the Java snippet from your initial post the `chararray` argument was an
*array* of `Byte` arrays. A string is just an one dimensional "byte
array". Maybe it helps if you put `chararray` into a list!?
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list