[Zope] Accepting XML requests

Oliver Bleutgen myzope@gmx.net
Wed, 11 Dec 2002 01:42:48 +0100


Peter Bengtsson wrote:
> I have set up a URL with a SMS-sending company.
> Basically, we set up so that
> http://ourhost:port/Folder/SMS/Receive
> should get the XML when someone sends an SMS to a particular number.
> 
> How do I in Zope, or rather, in this External Method accept the XML?
> Once I get the XML-Schema in as a string I'll know what to do with it, 
> but I'm not there yet.
> 
> [NB: Invoking the URL manually in the browser works and even though it's 
> just very basic debugging, it returns something without errors]
> If I try to standalone manually send an XML request using httplib as I 
> think they'll send it to us I get this error in response:
> 
> 
> 
>   <strong>Error Type: ResponseError</strong><br>
>   <strong>Error Value: <xmlrpclib.ResponseError instance at 
> 0x92b7ba4></strong><br>
> 
> Traceback (innermost last):
>   File 
> /local/home/peterbe/Zope-2.5.1-src/lib/python/ZPublisher/Publish.py, 
> line 150, in publish_module
>   File 
> /local/home/peterbe/Zope-2.5.1-src/lib/python/ZPublisher/Publish.py, 
> line 114, in publish
>   File /local/home/peterbe/Zope-2.5.1-src/lib/python/Zope/__init__.py, 
> line 159, in zpublisher_exception_hook
>     (Object: Zope)
>   File 
> /local/home/peterbe/Zope-2.5.1-src/lib/python/ZPublisher/Publish.py, 
> line 63, in publish
>   File 
> /local/home/peterbe/Zope-2.5.1-src/lib/python/ZPublisher/HTTPRequest.py, 
> line 357, in processInputs
>   File 
> /local/home/peterbe/Zope-2.5.1-src/lib/python/ZPublisher/xmlrpc.py, line 
> 47, in parse_input
>   File /local/home/peterbe/Zope-2.5.1-src/lib/python/xmlrpclib.py, line 
> 532, in loads
>   File /local/home/peterbe/Zope-2.5.1-src/lib/python/xmlrpclib.py, line 
> 369, in close
> ResponseError: (see above)
> 
> 
> 
> Why xmlrpclib?

Read the source, Luke ;)
In HTTPRequest.py:

     351             if (fs.headers.has_key('content-type') and
     352                 fs.headers['content-type'] == 'text/xml' and
     353                 method == 'POST'):
     354                 # Ye haaa, XML-RPC!
     355                 global xmlrpc
     356                 if xmlrpc is None: import xmlrpc
     357                 meth, self.args = xmlrpc.parse_input(fs.value)

Zope thinks you want to do xmlrpc, which you don't - I think you just 
want to get a string, which contains XML. That's not xml-rpc.

> Basically, how do I get the XML-Schema in as a string to work with from 
> the XML request?

I'd expect the request to come in as a normal HTTP-POST, encoded like a 
form (i.e. "application/x-www-form-urlencoded" or 
"multipart/form-data"), so that you can get to the encoded string using 
the standard methods.

HTH,
oliver