Re: [Zope] Problem with POST and text/xml (work-around)

2009-07-13 Thread Jonathan (dev101)
Problem:  zope interprets POST requests with a Content-Type of "text/xml" to 
be xmlrpc requests.

Work-around (requires Apache as a reverse proxy): use Apache to re-write the 
Content-Type header of the incoming request before it gets to zope using the 
following directives:

SetEnvIfNoCase Content-Type "text/xml" XMLFLAG
RequestHeader set Content-Type "application/xml" env=XMLFLAG

Zope then sees "text/xml" requests as "application/xml" requests and the xml 
data can then be accessed via "REQUEST['BODY']".

Thanks to Michael H. for the assistance!


Jonathan

___
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] Problem with POST and text/xml

2009-07-11 Thread Jonathan (dev101)
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Jonathan (dev101) wrote:
>> Just out of curiosity I ran a test using content-type of 
>> 'application/xml'
>> and zope does not raise the xmlrpc error (as it does with content-type of
>> 'text/xml'), but the POST content is not available within the REQUEST
>> object.
>>
>> This appears to be the same problem that I encountered using a 
>> content-type
>> of 'text/xml' with the xmlrpc test turned off (ie. no xmlrpc error, but 
>> no
>> POST data).
>>
>
> Look into REQUEST['BODY']
>
> Regards
> Michael

Most excellent, thanks!

I am now investing the possibility of using the RequestHeader directive of 
the Apache mod_header module to rewrite the content-type from "text/xml" to 
"application/xml" (we use Apache as a reverse proxy in front of zope).

If i get it to work I'll post the work-around...


Jonathan

___
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] Problem with POST and text/xml

2009-07-11 Thread Michael Haubenwallner
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jonathan (dev101) wrote:
> Just out of curiosity I ran a test using content-type of 'application/xml' 
> and zope does not raise the xmlrpc error (as it does with content-type of 
> 'text/xml'), but the POST content is not available within the REQUEST 
> object.
> 
> This appears to be the same problem that I encountered using a content-type 
> of 'text/xml' with the xmlrpc test turned off (ie. no xmlrpc error, but no 
> POST data).
> 

Look into REQUEST['BODY']

Regards
Michael

- --
http://blog.d2m.at
http://planetzope.org

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKWNBEl0uAvQJUKVYRArGwAJ42T66cvPKgQ8Zd+zt2BPT0QOV+2QCfXAfE
hRGby6U5HvDQ6hp0cZxrzXc=
=O1FU
-END PGP SIGNATURE-

___
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] Problem with POST and text/xml

2009-07-11 Thread Jonathan (dev101)

"Michael Haubenwallner"  wrote in message 
news:4a5898f5.8040...@d2m.at...
>
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Jonathan (dev101) wrote:
>> I need to support a third party web service (which is not within my 
>> control)
>> that wants to send xml data to my zope server (Zope 2.9.2 running on 
>> Redhat
>> linux).
>>
>> When Zope receives a POST request with a Content-Type of text/xml it 
>> assumes
>> that it is an xmlrpc call (which it is not - it is just passing xml data
>> within the POST request).
>>
>> Is there a way to get Zope to turn off this "xmlrpc assumption" so that 
>> my
>> zope external method can process the xml data that is being passed?
>>
>
> Did you think of using 'application/xml' instead of 'text/xml' ?
> Everything should work as expected.
>
> Regards
> Michael


Just out of curiosity I ran a test using content-type of 'application/xml' 
and zope does not raise the xmlrpc error (as it does with content-type of 
'text/xml'), but the POST content is not available within the REQUEST 
object.

This appears to be the same problem that I encountered using a content-type 
of 'text/xml' with the xmlrpc test turned off (ie. no xmlrpc error, but no 
POST data).

Does zope only make POST data available within the REQUEST object if the 
content-type is set to "application/x-www-form-urlencoded" or 
"multipart/form-data"?

Jonathan

___
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] Problem with POST and text/xml

2009-07-11 Thread Jonathan (dev101)
As a quick test I modified HTTPRequest.py to turn off the zope assumption 
that all POST requests with content-type of text/xml are xmlrpc requests.

This had the effect of eliminating the xmlrpc error that zope was raising, 
but a side effect is that the xml data is not available within the REQUEST 
object.

I don't think the patch submitted for bug 373663 will fix this behaviour 
(ie. it will resolve the xmlrpc error, but it won't make the xml data 
contained within the POST request available).

Any ideas on how to get access to the xml data?!  (and re-writing the entire 
app with Grok is not something I really want to do!)

Thanks,

Jonathan


___
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] Problem with POST and text/xml

2009-07-11 Thread Jonathan (dev101)

- Original Message - 
From: "Michael Haubenwallner" 
To: 
Sent: Saturday, July 11, 2009 9:51 AM
Subject: Re: [Zope] Problem with POST and text/xml


> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Jonathan (dev101) wrote:
>> I need to support a third party web service (which is not within my 
>> control)
>> that wants to send xml data to my zope server (Zope 2.9.2 running on 
>> Redhat
>> linux).
>>
>> When Zope receives a POST request with a Content-Type of text/xml it 
>> assumes
>> that it is an xmlrpc call (which it is not - it is just passing xml data
>> within the POST request).
>>
>> Is there a way to get Zope to turn off this "xmlrpc assumption" so that 
>> my
>> zope external method can process the xml data that is being passed?
>>
>
> Did you think of using 'application/xml' instead of 'text/xml' ?
> Everything should work as expected.
>
> Regards
> Michael

The POST requests are coming from a third party web service (which we don't 
control, and they have lots of other users) and they won't change the 
content-type just for us to work around a zope bug (sigh).






___
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] Problem with POST and text/xml

2009-07-11 Thread Michael Haubenwallner
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jonathan (dev101) wrote:
> I need to support a third party web service (which is not within my control) 
> that wants to send xml data to my zope server (Zope 2.9.2 running on Redhat 
> linux).
> 
> When Zope receives a POST request with a Content-Type of text/xml it assumes 
> that it is an xmlrpc call (which it is not - it is just passing xml data 
> within the POST request).
> 
> Is there a way to get Zope to turn off this "xmlrpc assumption" so that my 
> zope external method can process the xml data that is being passed?
> 

Did you think of using 'application/xml' instead of 'text/xml' ?
Everything should work as expected.

Regards
Michael

- --
http://blog.d2m.at
http://planetzope.org

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKWJj1l0uAvQJUKVYRAlZDAJ9a6wbEnRafVew2jPUttRmNjQKAtQCgh98/
kPSyOmTTHGBUSPmPy0V6Trw=
=s15f
-END PGP SIGNATURE-

___
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] Problem with POST and text/xml

2009-07-11 Thread Andreas Jung
On 11.07.09 15:22, Jonathan (dev101) wrote:
>
> There were some differences between my Zope 2.9.2 installation and the patch 
> instructions:
>
>   
Zope 2.9 is pretty much out-of-date.

-aj

-- 
ZOPYX Ltd. & Co KG  \  ZOPYX & Friends
Charlottenstr. 37/1  \  Das Expertennetzwerk für Python, Zope
D-72070 Tübingen  \  und Plone Projekte
www.zopyx.com, i...@zopyx.com  \  www.zopyx.de/friends, frie...@zopyx.de

E-Publishing, Python, Zope & Plone development, Consulting


begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:i...@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard

___
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] Problem with POST and text/xml

2009-07-11 Thread Jonathan (dev101)

>- Original Message - 
>From: "Andreas Jung" 
>To: "Jonathan (dev101)" 
>Cc: 
>Sent: Friday, July 10, 2009 4:30 PM
>Subject: Re: [Zope] Problem with POST and text/xml
>

> https://bugs.launchpad.net/zope2/+bug/373663
>
> -aj
>
> On 10.07.09 21:24, Jonathan (dev101) wrote:
>> I need to support a third party web service (which is not within my 
>> control)
>> that wants to send xml data to my zope server (Zope 2.9.2 running on 
>> Redhat
>> linux).
>>
>> When Zope receives a POST request with a Content-Type of text/xml it 
>> assumes
>> that it is an xmlrpc call (which it is not - it is just passing xml data
>> within the POST request).
>>
>> Is there a way to get Zope to turn off this "xmlrpc assumption" so that 
>> my
>> zope external method can process the xml data that is being passed?
>>
>>
>> Thanks,
>>
>> Jonathan

Thanks for the link!

There were some differences between my Zope 2.9.2 installation and the patch 
instructions:

1) There was no interfaces.py file in the ZPublisher source directory (so I 
created a new one)
2) There were some differences in the HTTPRequest.py file, but it was still 
possible to make the changes indicated in the patch instructions.

I restarted Zope via the ZMI, and ran a test (which generated a 500 response 
error). I noticed that there were no pyc/pyo files for interfaces.py and 
HTTPRequest.py, so I created them manually using py_compile.

I restarted Zope and ran another test (using wget to simulate a POST request 
containing xml data) and got a 503 response:

---response begin---
HTTP/1.0 503 Service Unavailable
Server: Zope/(Zope 2.9.2-, python 2.4.2, linux2) ZServer/1.1
Date: Sat, 11 Jul 2009 14:04:08 GMT
Bobo-Exception-Line: 402
Content-Length: 995
Bobo-Exception-Value: See the server error log for details
Content-Type: text/html; charset=iso-8859-15
Bobo-Exception-Type: NameError
Connection: Keep-Alive
Bobo-Exception-File: HTTPRequest.py


There were no entries in Z2.log or event.log.

Other than manually creating pyc/pyo files and re-starting zope, is there 
anything else I need to do to implement the changes to interfaces.py and 
HTTPRequest.py?  If not, any ideas as to what could be causing this error or 
how I could go about debugging it?


Thanks,

Jonathan


___
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] Problem with POST and text/xml

2009-07-11 Thread Peter Bengtsson
Roughly because of this I ended up writing the web service part of the
app in Grok instead of Zope.

2009/7/10 Jonathan (dev101) :
> I need to support a third party web service (which is not within my control)
> that wants to send xml data to my zope server (Zope 2.9.2 running on Redhat
> linux).
>
> When Zope receives a POST request with a Content-Type of text/xml it assumes
> that it is an xmlrpc call (which it is not - it is just passing xml data
> within the POST request).
>
> Is there a way to get Zope to turn off this "xmlrpc assumption" so that my
> zope external method can process the xml data that is being passed?
>
>
> Thanks,
>
> Jonathan
>
>
> P.S.  details of a wget session that illustrate the error being generated
> follows:
>
> Setting --header (header) to Content-Type: text/xml
> Setting --post-data (postdata) to  ?>
> 
>  235006
>  1160
>  test #27
>  2007-09-14 15:52:59
>  +11234567890
>  26
>  Sprint
>  5
>  
> DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnu.
>
> --16:12:28--  http://192.168.123.2:8080/Coz/Process3Ci
>           => `Process3Ci.1'
> Connecting to 192.168.123.2:8080... connected.
> Created socket 3.
> Releasing 0x00638c60 (new refcount 0).
> Deleting unused 0x00638c60.
>
> ---request begin---
> POST /Coz/Process3Ci HTTP/1.0
> User-Agent: Wget/1.10.2 (Red Hat modified)
> Accept: */*
> Host: 192.168.123.2:8080
> Connection: Keep-Alive
> Content-Type: text/xml
> Content-Length: 390
>
> ---request end---
> [POST data: 
> 
>  235006
>  1160
>  test #27
>  2007-09-14 15:52:59
>  +11234567890
>  26
>  Sprint
>  5
>  ]
> HTTP request sent, awaiting response...
> ---response begin---
> HTTP/1.0 500 Internal Server Error
> Server: Zope/(Zope 2.9.2-, python 2.4.2, linux2) ZServer/1.1
> Date: Fri, 10 Jul 2009 20:12:28 GMT
> Bobo-Exception-Line: 742
> Content-Length: 849
> Bobo-Exception-Value: See the server error log for details
> Content-Type: text/html; charset=iso-8859-15
> Bobo-Exception-Type: ResponseError
> Connection: Keep-Alive
> Bobo-Exception-File: xmlrpclib.py
>
> ---response end---
> 500 Internal Server Error
> Registered socket 3 for persistent reuse.
>
>
> ___
> Zope maillist  -  z...@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 )
>



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
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] Problem with POST and text/xml

2009-07-10 Thread Andreas Jung
https://bugs.launchpad.net/zope2/+bug/373663

-aj

On 10.07.09 21:24, Jonathan (dev101) wrote:
> I need to support a third party web service (which is not within my control) 
> that wants to send xml data to my zope server (Zope 2.9.2 running on Redhat 
> linux).
>
> When Zope receives a POST request with a Content-Type of text/xml it assumes 
> that it is an xmlrpc call (which it is not - it is just passing xml data 
> within the POST request).
>
> Is there a way to get Zope to turn off this "xmlrpc assumption" so that my 
> zope external method can process the xml data that is being passed?
>
>
> Thanks,
>
> Jonathan
>
>
> P.S.  details of a wget session that illustrate the error being generated 
> follows:
>
> Setting --header (header) to Content-Type: text/xml
> Setting --post-data (postdata) to  ?>
> 
>   235006
>   1160
>   test #27
>   2007-09-14 15:52:59
>   +11234567890
>   26
>   Sprint
>   5
>  
> DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnu.
>
> --16:12:28--  http://192.168.123.2:8080/Coz/Process3Ci
>=> `Process3Ci.1'
> Connecting to 192.168.123.2:8080... connected.
> Created socket 3.
> Releasing 0x00638c60 (new refcount 0).
> Deleting unused 0x00638c60.
>
> ---request begin---
> POST /Coz/Process3Ci HTTP/1.0
> User-Agent: Wget/1.10.2 (Red Hat modified)
> Accept: */*
> Host: 192.168.123.2:8080
> Connection: Keep-Alive
> Content-Type: text/xml
> Content-Length: 390
>
> ---request end---
> [POST data: 
> 
>   235006
>   1160
>   test #27
>   2007-09-14 15:52:59
>   +11234567890
>   26
>   Sprint
>   5
>  ]
> HTTP request sent, awaiting response...
> ---response begin---
> HTTP/1.0 500 Internal Server Error
> Server: Zope/(Zope 2.9.2-, python 2.4.2, linux2) ZServer/1.1
> Date: Fri, 10 Jul 2009 20:12:28 GMT
> Bobo-Exception-Line: 742
> Content-Length: 849
> Bobo-Exception-Value: See the server error log for details
> Content-Type: text/html; charset=iso-8859-15
> Bobo-Exception-Type: ResponseError
> Connection: Keep-Alive
> Bobo-Exception-File: xmlrpclib.py
>
> ---response end---
> 500 Internal Server Error
> Registered socket 3 for persistent reuse.
>
>
> ___
> 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 )
>   


-- 
ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany
Web: www.zopyx.com - Email: i...@zopyx.com - Phone +49 - 7071 - 793376
Registergericht: Amtsgericht Stuttgart, Handelsregister A 381535
Geschäftsführer/Gesellschafter: ZOPYX Limited, Birmingham, UK

E-Publishing, Python, Zope & Plone development, Consulting


begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:i...@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard

___
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 )