Re: [Zope] Sending XML straight down to a zope
On Thu, Oct 12, 2006 at 09:16:30PM +0200, Dieter Maurer wrote: Chris Withers wrote at 2006-10-12 08:35 +0100: Peter Bengtsson wrote: xml_content = open('validxmlfile.xml').read() http = httplib.HTTP(localhost, 8080) http.putrequest(POST, /uploadExpenseXML) That's not really a valid transaction... Why not? The real problem is that Zope wrongfully assumes that each POST with content type text/xml is an XML-RPC request. That's wrong at least since XML is more widely used on the browser side (e.g. XForms). XML-RPC is not very helpful here. As usual, its extreme simplicity is both a blessing and a curse. The specification, http://www.xmlrpc.com/spec , specifies POST with content-type of text/xml, and that's all; so you really can't distinguish XML-RPC from any other xml POST just from the header. I suppose the publisher could cheat a bit and look in the body for the required methodCall element. If missing, it can't be XML-RPC. It would be more reliable if some configuration was required to specify when XMLRPC is expected, and when not. But that would break Zope's longstanding promise that XMLRPC is supported for free, always, automatically. -- Paul Winkler http://www.slinkp.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Sending XML straight down to a zope
Peter Bengtsson wrote: xml_content = open('validxmlfile.xml').read() http = httplib.HTTP(localhost, 8080) http.putrequest(POST, /uploadExpenseXML) That's not really a valid transaction... My guess is you should be encoding this as a posted file (ie: as if you'd used an input type=file/) and then process the file on the server... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Sending XML straight down to a zope
Chris Withers wrote: Peter Bengtsson wrote: xml_content = open('validxmlfile.xml').read() http = httplib.HTTP(localhost, 8080) http.putrequest(POST, /uploadExpenseXML) That's not really a valid transaction... Perhaps I got my pseudo syntax code wrong. My point is still valid since Zope doesn't seem to be able to deconstruct a HTTP POST where a value is send without a key. My guess is you should be encoding this as a posted file (ie: as if you'd used an input type=file/) and then process the file on the server... I've tried to make them change their mind now about how they post it to me but it's a bit unclear still if they can change their minds about how the XML poster works. So you don't know of a way to get the value of the posted body in zope? -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Sending XML straight down to a zope
Chris Withers wrote at 2006-10-12 08:35 +0100: Peter Bengtsson wrote: xml_content = open('validxmlfile.xml').read() http = httplib.HTTP(localhost, 8080) http.putrequest(POST, /uploadExpenseXML) That's not really a valid transaction... Why not? The real problem is that Zope wrongfully assumes that each POST with content type text/xml is an XML-RPC request. That's wrong at least since XML is more widely used on the browser side (e.g. XForms). -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Sending XML straight down to a zope
I'm trying to send an XML straight into Zope without specifying it as a parameter and with a Content-Length. It seems that Zope's mapply function or whatever it's called digests the raw http body and tries to turn it into parameters? Here's the code on the Zope server (uploadExpenseXML()): def uploadExpenseXML(self): return str(self.REQUEST.form.keys()) Here's the dummy code that sends the XML into my Zope: xml_content = open('validxmlfile.xml').read() http = httplib.HTTP(localhost, 8080) http.putrequest(POST, /uploadExpenseXML) http.putheader(User-Agent, Simple) http.putheader(Host, localhost) http.putheader(Content-Length, %d % len(xml_content)) http.endheaders() http.send(xml_content) reply, message, headers = http.getreply() print http.getfile().read() The result I get is: ['?xml version'] If I debug the value of that single REQUEST.form variable, it starts like this: '1.0 encoding=ISO-8859-1 standalone=yes ?\nXMLExpense Version=1.0 Obviously, one solution would be to ask the XML sending company to not post it like this but instead post it by parameter which I know will work. But, what if I can't change their minds? PS. When faced with the same problem a long time ago I ended up writing a mod_python app running one a different port that converted the http post from mod_python into a parameter based http post. I don't want to have to do that again. -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )