473,587 Members | 2,487 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 2775
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
6846
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 the fun I can use xmlrpc w/timeoutsocket if calling functions at the ubiquitous betty.userland.com...
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" /> </server>
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
6051
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 error. Can I ask a simple question to start with: I'm trying to read the file using the...
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 Myrta wrote:
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 return characters when
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 displayed:
5
28421
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
7923
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
8349
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...
0
6629
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
5719
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
5395
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
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
1455
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.