473,583 Members | 3,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xmlrpclib and binary data as normal parameter strings

Trying something like::
import xmlrpclib
svr = xmlrpclib.Serve r("http://127.0.0.1:8000" )
svr.test("\x1bt est")

Failes on the server with::
xml.parsers.exp at.ExpatError: not well-formed (invalid token)

(Smaller test-case: xmlrpclib.loads (xmlrpclib.dump s(('\x1btest',) )))

Shouldn't this be allowed?

From http://www.xmlrpc.com/spec ::
Any characters are allowed in a string except < and &, which are
encoded as &lt; and &amp;. A string can be used to encode binary
data.

From http://www.w3.org/TR/2004/REC-xml11-.../#dt-character ::
Consequently, XML processors MUST accept any character in the range
specified for Char
...
Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

(I'm aware that xmlrpclib.Binar y can be used as an ugly work-around.)

--
Rune Frøysa
Jul 19 '05 #1
3 2774
Rune Froysa wrote:
From http://www.w3.org/TR/2004/REC-xml11-.../#dt-character ::

Consequently, XML processors MUST accept any character in the range
specified for Char
...
Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]


you're looking at the XML 1.1 specification. don't do that. nobody uses 1.1.

here's the 1.0 version:

http://www.w3.org/TR/REC-xml/#dt-character

Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

</F>

Jul 19 '05 #2

"Rune Froysa" <ru*********@us it.uio.no> wrote in message news:sv******** *****@dresden.u io.no...
From http://www.xmlrpc.com/spec ::
Any characters are allowed in a string except < and &, which are
encoded as &lt; and &amp;. A string can be used to encode binary
data.
the XMLRPC specification is worded pretty loosely. Obviously characters
forbidden in XML will be problematic.
From http://www.w3.org/TR/2004/REC-xml11-.../#dt-character ::


That's XML 1.1; it's very rarely used in practice. Can XMLRPC use XML 1.1?
In principle, undefined, as far as I know. In practice, not in Python anyway.
Jul 19 '05 #3
"Richard Brodie" <R.******@rl.ac .uk> writes:
"Rune Froysa" <ru*********@us it.uio.no> wrote in message news:sv******** *****@dresden.u io.no...
From http://www.xmlrpc.com/spec ::
Any characters are allowed in a string except < and &, which are
encoded as &lt; and &amp;. A string can be used to encode binary
data.


the XMLRPC specification is worded pretty loosely. Obviously characters
forbidden in XML will be problematic.


IMHO that is not obvious. The API-user wants to call a function on a
remote server with an arbitrary argument. What the transport-layer
does to achieve this should be completly transparent to the user.

We already have code that takes care of "&<>". Ideally we should do
that for other data as well. Unfortunately the XML-spec doesn't allow
us to use character references "&%#x1b;".

With the patch below, setting BINARY_AS_STRIN G=True will cause all
strings to be transparently base64-encoded during transport.
Unfortunately it will do this for all incoming binary data, thus
breaking aplications that explicitly uses the Binary class for this
purpose.

IMHO the xmlrpc spec should be updated to allow something like this.

--- /local/lib/python2.3/xmlrpclib.py 2005-01-10 10:30:43.000000 000 +0100
+++ xmlrpclib.py 2005-04-20 09:56:11.000000 000 +0200
@@ -177,6 +177,8 @@

__version__ = "1.0.1"

+BINARY_AS_STRI NG = False
+
# xmlrpc integer limits
MAXINT = 2L**31-1
MININT = -2L**31
@@ -652,6 +654,11 @@
dispatch[FloatType] = dump_double

def dump_string(sel f, value, write, escape=escape):
+ if BINARY_AS_STRIN G:
+ self.write = write
+ Binary(value).e ncode(self)
+ del self.write
+ return
write("<value>< string>")
write(escape(va lue))
write("</string></value>\n")
@@ -843,7 +850,10 @@
def end_base64(self , data):
value = Binary()
value.decode(da ta)
- self.append(val ue)
+ if BINARY_AS_STRIN G:
+ self.append(val ue.data)
+ else:
+ self.append(val ue)
self._value = 0
dispatch["base64"] = end_base64

--
Rune Frøysa
Jul 19 '05 #4

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

Similar topics

3
6843
by: herc777 | last post by:
I want to manipulate binary files. this was just a test to concatinate 2 text files but it said file_put_contents was undefined. the second parameter is suppoed to be 'mixed data', no idea what that is. <?php $t1 = file_get_contents('test1.txt'); $t2 = file_get_contents('test2.txt'); $result = file_put_contents('test3.txt', $t1 . $t2);
0
1761
by: Larry | last post by:
I've had a production system running for a long time that uses xmlrpclib with timeoutsocket, and with my recent upgrade to 2.3 it's no longer able to use xmlrpclib with the xmlrpc servers I communicate with. I can call remote procedures still, but as soon as I import timeoutsocket and the old socket switcharoo is done it's over. To add to...
0
1117
by: Alan Little | last post by:
I'm trying to write a generic weblog update notifier using xmlrpclib, starting with technorati. What I want to do is something like this : XML config file that would look like this: <server url="http//whatever,technorati.org" methodname="technoratiMethod"> <param sequence="1" source="myAttrib1" /> <param sequence="2" source="myAttrib2"...
4
3148
by: nightflyer | last post by:
Hi all, [code snippet appended at the end.) my question: A class has a few string variables with not know length at design time. Now I declare lets say a 1000 of those classes and put them in a vector. Can I write that vector directly to a binary file?
7
6050
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should populate a series of structures of specified variable composition. I have the structures created OK, but actually reading the files is giving me an...
2
5254
by: Bastian Voigt | last post by:
Hallo List! I just found this old posting on google. Now my question is how can I read an integer value from the PGresult using the binary format? Can someone plz gimme a code example? (please mail to me, because I have not subscribed to the list) Thanks a bunch! Now here's the old posting: On Monday 27 October 2003 09:15, Tomasz...
5
2074
by: Jonathan Ballet | last post by:
Hello, I have developped a XMLRPC server, which runs under Gnu/Linux with python2.3. This server receives method calls from Windows client. The server got some parameters which are string, which contains carriage return characters, just after the line feed character; like "bla\n\rbla". The problem is, xmlrpclib "eats" those carriage...
0
1643
by: Arno Stienen | last post by:
Perhaps I should be a bit more specific. When using this code to connect to a remote XML-RPC server (C++, xmlrpc++0.7 library): import xmlrpclib server = xmlrpclib.Server("http://10.10.101.62:29500") print server.Connection_Request("roberto") the Python command line 'hangs' until I kill the server. Then, the correct output is suddenly...
5
28420
by: gezerpunta | last post by:
Hi strlen does not return the correct value .I compared the filesize() and strlen byte size but they are not equal. I must find binary string length and it must be equal to filesize() thks.
0
7827
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...
0
8184
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8328
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...
1
7936
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...
0
6581
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...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.