[Seaside] WAResponse and XML

Philippe Marschall philippe.marschall at gmail.com
Thu Aug 4 06:04:05 UTC 2011


2011/8/4 Jay Hardesty <jayh at panix.com>:
>
> Hi - I'm having a problem returning XML as a response from within a Seaside app, after moving to 3.0.
>
> I used to return XML by:
>
>        self session returnResponse:
>                (WAResponse new
>                        contentType: 'text/xml';
>                        nextPutAll: xmlString;
>                        yourself)
>
> but t in Seaside 3.0 I get:
>        'You can no longer return a new WAResponse instance. You must instead modify the Response contained in the active RequestContext. Look for senders of #respond: and #response for examples.'
>
>
> Following the nearest examples I can find I tried:
>
>        self requestContext respond: [:response |
>                | document |
>                document := MIMEDocument
>                        contentType: 'text/xml';
>                        content: xmlString.
>                response document: document]
>
> and:
>
>        self requestContext respond: [:response |
>                response
>                        contentType: 'text/xml';
>                        nextPutAll: xmlString]
>
> but in both cases an html document arrives downstream (with XML in the body) rather than the XML itself as previously
>
> Think I'm missing something basic here... Thanks very much for any pointers,

That should absolutely work. The sample code below works for me.
You'll probably want to test with Firefox because it renders XML
nicely.

renderContentOn: html
	html anchor
		callback: [
			self requestContext respond: [ :response |
				response
					contentType: 'text/xml';
					nextPutAll: '<?xml version="1.0"
encoding="UTF-8"?><hello><world/></hello>' ] ];
		with: 'XML'

Cheers
Philippe


More information about the seaside mailing list