473,804 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Byte array question

Hi all,

I'm trying to write through SOAPpy in python to a Java implemented API.
The API for the method I want to use is as follows:

boolean added = SoapService.add AttachmentsToIs sue(token,
issue.getKey(),
new String[]{fileName},
new byte[][]{getBytesFromFi le(tmpFile)});

I've got everything covered except for the byte array. The byte array
should be holding the contents of the attachment(s) 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.

How can I mimic a byte array in python? Suggestions on things to try?

Jul 13 '06 #1
8 3146
Sybren Stuvel wrote:
da********@gmai l.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.addAttachm entsToIssue(aut h,'TST-4','testfile.tx t',chararray)

<fails with>
SOAPpy.Types.fa ultType: <Fault soapenv:Server. userException:
org.xml.sax.SAX Exception: Found character data inside an array element
while deserializing: <SOAPpy.Types.s tructType detail at -1216265236>:
{'hostname': '<removed>', 'faultData': <SOAPpy.Types.s tructType
faultData at -1216226708>: {'exception': None, 'message': 'Found
character data inside an array element while deserializing'} }>

<'nother snippet>
fileobj = open('testfile. txt', mode='r')
chararray = array.array('c' )
chararray.fromf ile(fileobj, stat('testfile. txt').st_size)
fileobj.close()

soap.addAttachm entsToIssue(aut h,'TST-4','testfile.tx t',chararray)

<fails with>
SOAPpy.Types.fa ultType: <Fault soapenv:Server. userException:
org.xml.sax.SAX Exception: Found character data inside an array element
while deserializing: <SOAPpy.Types.s tructType detail at -1216482740>:
{'hostname': '<removed>', 'faultData': <SOAPpy.Types.s tructType
faultData at -1216075252>: {'exception': None, 'message': 'Found
character data inside an array element while deserializing'} }>

<'nother snippet>
fileobj = open('testfile. txt', mode='r')
chararray = array.array('c' )
chararray.fromf ile(fileobj, stat('testfile. txt').st_size)
#chararray = fileobj.read()
fileobj.close()

soap.addAttachm entsToIssue(aut h,'TST-4','testfile.tx t',[chararray])

This one "works" in that it runs, but the server on the other end gets
garbage unrelated to the test file.

I've tried a few other other ideas including other modes for the array
(b/B), but those are the highlights.

Jul 13 '06 #2

Sybren Stuvel wrote:
Dan Winsor enlightened us with:
This one "works" in that it runs, but the server on the other end gets
garbage unrelated to the test file.

Are you sure it is garbage? Have you tried changing byte order?
Ah, that I hadn't. Any pointers to doing that?

Jul 14 '06 #3
On 14/07/2006 10:41 AM, Dan Winsor wrote:
Sybren Stuvel wrote:
>Dan Winsor enlightened us with:
>>This one "works" in that it runs, but the server on the other end gets
garbage unrelated to the test file.
Are you sure it is garbage? Have you tried changing byte order?

Ah, that I hadn't. Any pointers to doing that?
You found array.array.byt eswap() in the manual and rejected it because ...?

Jul 14 '06 #4

John Machin wrote:
On 14/07/2006 10:41 AM, Dan Winsor wrote:
Sybren Stuvel wrote:
Dan Winsor enlightened us with:
This one "works" in that it runs, but the server on the other end gets
garbage unrelated to the test file.
Are you sure it is garbage? Have you tried changing byte order?
Ah, that I hadn't. Any pointers to doing that?

You found array.array.byt eswap() in the manual and rejected it because ...?
....you suggested it? :)

Jul 14 '06 #5
In <11************ **********@b28g 2000cwb.googleg roups.com>, Dan Winsor
wrote:
Sybren Stuvel wrote:
>da********@gmai l.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.addAttachm entsToIssue(aut h,'TST-4','testfile.tx t',chararray)

<fails with>
SOAPpy.Types.fa ultType: <Fault soapenv:Server. userException:
org.xml.sax.SAX Exception: Found character data inside an array element
while deserializing: <SOAPpy.Types.s tructType detail at -1216265236>:
{'hostname': '<removed>', 'faultData': <SOAPpy.Types.s tructType
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
Jul 14 '06 #6
Marc 'BlackJack' Rintsch wrote:
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!?
Yup, thanks, that was one that I did try with no improvement:
fileobj = open('testfile. txt', mode='r')
chararray = fileobj.read()
fileobj.close()

soap.addAttachm entsToIssue(aut h,'TST-4','scriptattac h.txt',[chararray])

fails with:
SOAPpy.Types.fa ultType: <Fault Server.userExce ption: No such operation
'addAttachments ToIssue': <SOAPpy.Types.s tructType detail at
-1216379924>: {'hostname': '<removed>'}>

which is an uglier and less informative trace unfortunately. Thanks,
though.

Jul 14 '06 #7

John Machin wrote:
On 14/07/2006 10:41 AM, Dan Winsor wrote:
Sybren Stuvel wrote:
Dan Winsor enlightened us with:
This one "works" in that it runs, but the server on the other end gets
garbage unrelated to the test file.
Are you sure it is garbage? Have you tried changing byte order?
Ah, that I hadn't. Any pointers to doing that?

You found array.array.byt eswap() in the manual and rejected it because ...?
Unfortunately, this yielded similar results as not byte swapping it.
Thanks for the pointer, though.

Jul 14 '06 #8
Nevermind. Did it in Java. Thanks anyway to all who gave suggestions.

Jul 14 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6320
by: Harry Overs | last post by:
My program needs to take a pointer to BYTE array (unsigned char*) and convert it into a STL list so that each BYTE in the array has its own element in the list, i.e. if the array has hundred bytes then the list needs to have a hundred entries, at present when I try to do this each element in my list points to the entire BYTE array, when what I really need is copies of each single BYTE in its own part of the list. I have used code similar...
19
4164
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
13
2165
by: Ray Z | last post by:
So far, I get the idea that if I want to use both the unmanaged and managed memory, I can not avoid memory copy. But I DO need to avoid it. I get a idea that maybe I could use "union" to convert byte to int and so on. Here is my source code, I wonder if this will work with GC? struct MyUnion {
3
9517
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At the end of this message is the inflate method this is where I get stuck I know that I need a byte array but because I am decompressing a string I have no idea of how big the byte array will need to be in the end (the inflate and deflate methods...
8
10722
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
2
3596
by: Bryan | last post by:
Apologies if this is a noob question, but I've been struggling with this for quite a while... I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string that is displayed in a text box. Once displayed, the text will be copied, transmitted and then pasted (all manually by humans) into a second utility where the string must then be reverse-engineered into the *original* byte array. The byte array will...
32
6377
by: Guoqi Zheng | last post by:
I am really do not know so much about byte/bit, etc. Question, if I defined a byte(), how can I add a single byte to it? what I want is that I have an array of bytes, I loop that array, look at the value of that individual byte, if that byte is what I want, then I insert it into the new byte(). How can I do it? -- Kind regards
6
4683
by: Vitaly Zayko | last post by:
It's probably simple but I can't find a way how to copy number of bytes from one byte array to another? Just like Array.Copy(SourceArray, SourceIndex, DestArray, DestIndex, Length) does but in my case the arrays have different length. Of course I can copy byte by byte but I guess there should be a function for such task. Thanks! -- Vit Zayko
1
1445
by: Steve Marshall | last post by:
Hi all, This is probably a real dumb question, but I just haven't come across the answer... Is there a simple way to treat a byte array as a string, or to convert it to a string? And the converse would sometimes be useful too, i.e. convert/treat string as byte array. Thanks
11
5283
by: chaitali.pats | last post by:
Hi , I have implemented MD5 in C language . I am getting an output of 32 bits Hexadecimal number . for example : 83a80d3ca057492f0ce99ac1db8dced0 I need to convert this string same to 16 byte array. Can anyone help me ?
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.