WAResponse and XML

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

WAResponse and XML

jayh

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,
Jay


 


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jgfoster
Jay,

With the following code, clicking on a link will open a dialog asking what application to use to open the document or offering to save the document. This looks close to what you are doing. (I'm using Seaside 3.0.5 in GemStone/S.)

James

        self requestContext respond: [:response |
                | document |
                document := myXmlString seasideMimeDocument
                        mimeType: (WAFileLibrary mimetypeFor: 'xml');
                        fileName: 'myNewFile.xml';
                        yourself.
                response
                        document: document;
                        doNotCache;
                        yourself.
        ].

On Aug 3, 2011, at 4:09 PM, Jay Hardesty wrote:

>
> 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,
> Jay
>
>
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh
Thank you for the response, James.   

For me, the problem is that I need the XML to be processed automatically (with no dialog).

Whereas my response from Seaside used to return XML - that is something starting with:
<?xml version="1.0" encoding="UTF-8"?...  (because that's how my xmlString starts)

I instead now see something starting:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

For instance the response returned from the code fragment in your response ultimately arrives as the same (html) result 

I should mention that this particular request is being sent to my Seaside app from a non-Seaside client; perhaps a Seaside app simply can't be used in such a way anymore(?)  

Thanks again,
Jay


On Aug 4, 2011, at 1:27 AM, James Foster wrote:

Jay,

With the following code, clicking on a link will open a dialog asking what application to use to open the document or offering to save the document. This looks close to what you are doing. (I'm using Seaside 3.0.5 in GemStone/S.)

James

self requestContext respond: [:response |
| document |
document := myXmlString seasideMimeDocument
mimeType: (WAFileLibrary mimetypeFor: 'xml');
fileName: 'myNewFile.xml';
yourself.
response
document: document;
doNotCache;
yourself.
].

On Aug 3, 2011, at 4:09 PM, Jay Hardesty wrote:


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,
Jay





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh
In fact I assume I really need to push this functionality down to the purely HTTP level.

Situation arose because I've been reusing my Seaside apps to serve data to other sorts of clients as well - overkill I guess since I'm not using any generated html in such cases 


On Aug 4, 2011, at 1:53 AM, Jay Hardesty wrote:

Thank you for the response, James.   

For me, the problem is that I need the XML to be processed automatically (with no dialog).

Whereas my response from Seaside used to return XML - that is something starting with:
<?xml version="1.0" encoding="UTF-8"?...  (because that's how my xmlString starts)

I instead now see something starting:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

For instance the response returned from the code fragment in your response ultimately arrives as the same (html) result 

I should mention that this particular request is being sent to my Seaside app from a non-Seaside client; perhaps a Seaside app simply can't be used in such a way anymore(?)  

Thanks again,
Jay


On Aug 4, 2011, at 1:27 AM, James Foster wrote:

Jay,

With the following code, clicking on a link will open a dialog asking what application to use to open the document or offering to save the document. This looks close to what you are doing. (I'm using Seaside 3.0.5 in GemStone/S.)

James

self requestContext respond: [:response |
| document |
document := myXmlString seasideMimeDocument
mimeType: (WAFileLibrary mimetypeFor: 'xml');
fileName: 'myNewFile.xml';
yourself.
response
document: document;
doNotCache;
yourself.
].

On Aug 3, 2011, at 4:09 PM, Jay Hardesty wrote:


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,
Jay





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

Philippe Marschall
In reply to this post by jayh
2011/8/4 Jay Hardesty <[hidden email]>:

>
> 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
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

Philippe Marschall
In reply to this post by jayh
2011/8/4 Jay Hardesty <[hidden email]>:

> Thank you for the response, James.
> For me, the problem is that I need the XML to be processed automatically
> (with no dialog).
> Whereas my response from Seaside used to return XML - that is something
> starting with:
> <?xml version="1.0" encoding="UTF-8"?...  (because that's how my xmlString
> starts)
> I instead now see something starting:
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...
> For instance the response returned from the code fragment in your response
> ultimately arrives as the same (html) result
> I should mention that this particular request is being sent to my Seaside
> app from a non-Seaside client; perhaps a Seaside app simply can't be used in
> such a way anymore(?)

What do you mean with non-Seaside client? Is it a non-browser
application, non-HTML application? In those cases you can still use
Seaside. You can either directly write RequestHandlers or you can have
a look at Seaside-REST.

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh
In reply to this post by Philippe Marschall

On Aug 4, 2011, at 8:04 AM, Philippe Marschall wrote:

> 2011/8/4 Jay Hardesty <[hidden email]>:
>>
>> 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
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


Thank you Phillipe - Yes, your code works for me just as you described.

I guess my problem is that I want my renderContentOn: to immediately return XML in certain circumstances without any user action.  As in this variation on your code example:

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

If I call this from Firefox, then instead of XML (as in your example) I see
        "XML Parsing Error: XML or text declaration not at start of entity[...]"  
and viewing the page source gives:
        "<!DOCTYPE html PUBLIC [...]"


Whereas my old code:

        renderContentOn: html
                self session returnResponse:
                        (WAResponse new
                                contentType: 'text/xml';
                                nextPutAll: <?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ;
                                yourself)

returned and displayed XML just as your example, but without any user action

So what I'm apparently missing is whatever magic happens as a result of the anchor callback being fired in your example.  I wonder if there's any way to get that kind of callback behavior programatically(?)


> What do you mean with non-Seaside client? Is it a non-browser
> application, non-HTML application? I


Yes, I'm using Seaside apps to serve (music score data) to
- Seaside web client
- Flash web client
- iPhone app
- code running in Second Life
- Croquet environment

> In those cases you can still use
> Seaside. You can either directly write RequestHandlers or you can have
> a look at Seaside-REST.

Interesting - I'll try to find an example using WARequestHandler, though I suppose this will mean moving the functionality out of my Seaside app (WAComponent subclass)...

Thanks very much for the tips, and for your example which has helped me narrow the scope of the problem

Best regards
Jay








_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

Philippe Marschall
2011/8/4 Jay Hardesty <[hidden email]>:

>
> On Aug 4, 2011, at 8:04 AM, Philippe Marschall wrote:
>
>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>
>>> 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
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> Thank you Phillipe - Yes, your code works for me just as you described.
>
> I guess my problem is that I want my renderContentOn: to immediately return XML in certain circumstances without any user action.  As in this variation on your code example:
>
>        renderContentOn: html
>                self requestContext respond: [ :response |
>                        response
>                                contentType: 'text/xml';
>                                nextPutAll: '<?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ]

That doesn't work. Components are made to generate HTML and in this
case a lot of HTML (<DOCTYPE>, <head>, <body>, …) has already been
generated. You have two options. First you can configure your
components to generate XML. See Seaside-WebServices-Core and
Seaside-Tests-WebServices in the addons repository [1] for examples.
However unless you need #call: and callbacks and friends I found
recommend to use Seaside-REST, also from the addons repository. There
is a short overview on the wiki [2] and you can find some examples
here [3].


> If I call this from Firefox, then instead of XML (as in your example) I see
>        "XML Parsing Error: XML or text declaration not at start of entity[...]"
> and viewing the page source gives:
>        "<!DOCTYPE html PUBLIC [...]"
>
>
> Whereas my old code:
>
>        renderContentOn: html
>                self session returnResponse:
>                        (WAResponse new
>                                contentType: 'text/xml';
>                                nextPutAll: <?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ;
>                                yourself)
>
> returned and displayed XML just as your example, but without any user action
>
> So what I'm apparently missing is whatever magic happens as a result of the anchor callback being fired in your example.  I wonder if there's any way to get that kind of callback behavior programatically(?)
>
>
>> What do you mean with non-Seaside client? Is it a non-browser
>> application, non-HTML application? I
>
>
> Yes, I'm using Seaside apps to serve (music score data) to
> - Seaside web client
> - Flash web client
> - iPhone app
> - code running in Second Life
> - Croquet environment
>
>> In those cases you can still use
>> Seaside. You can either directly write RequestHandlers or you can have
>> a look at Seaside-REST.
>
> Interesting - I'll try to find an example using WARequestHandler, though I suppose this will mean moving the functionality out of my Seaside app (WAComponent subclass)...

Yes. You can look at WAFileHandler for a complicated examples, for
simple ones look at Seaside-Benchmark in the addons repository [1].

> Thanks very much for the tips, and for your example which has helped me narrow the scope of the problem
>

 [1] http://www.squeaksource.com/Seaside30Addons
 [2] http://code.google.com/p/seaside/wiki/SeasideRest
 [3] http://www.squeaksource.com/orion

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

Bob Nemec
In reply to this post by jayh
We interface with an IVR system by answering VXML. I ended up subclassing WARequestHandler and implemented #handleFiltered: as indicated in the class comments.

Here is a simplified version of the method...
handleFiltered: aRequestContext
| response result request | 
request := aRequestContext request.
result := self processCall: request.
response := aRequestContext response. 
response 
contentType: self contentType; 
nextPutAll: result.
aRequestContext respond.

...where #processCall: answers a VXML string based on the request contents (using #aRequest>>at:ifPresent:)

That, plus a class initialize method...
^WAAdmin register: self at: 'IVR'
...was all that was needed to get started. 

The same image also serves a full Seaside interface for the IVR application. 

Bob Nemec



On Wed, Aug 3, 2011 at 8:01 PM, Jay Hardesty <[hidden email]> wrote:
In fact I assume I really need to push this functionality down to the purely HTTP level.

Situation arose because I've been reusing my Seaside apps to serve data to other sorts of clients as well - overkill I guess since I'm not using any generated html in such cases 


On Aug 4, 2011, at 1:53 AM, Jay Hardesty wrote:

Thank you for the response, James.   

For me, the problem is that I need the XML to be processed automatically (with no dialog).

Whereas my response from Seaside used to return XML - that is something starting with:
<?xml version="1.0" encoding="UTF-8"?...  (because that's how my xmlString starts)

I instead now see something starting:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

For instance the response returned from the code fragment in your response ultimately arrives as the same (html) result 

I should mention that this particular request is being sent to my Seaside app from a non-Seaside client; perhaps a Seaside app simply can't be used in such a way anymore(?)  

Thanks again,
Jay


On Aug 4, 2011, at 1:27 AM, James Foster wrote:

Jay,

With the following code, clicking on a link will open a dialog asking what application to use to open the document or offering to save the document. This looks close to what you are doing. (I'm using Seaside 3.0.5 in GemStone/S.)

James

self requestContext respond: [:response |
| document |
document := myXmlString seasideMimeDocument
mimeType: (WAFileLibrary mimetypeFor: 'xml');
fileName: 'myNewFile.xml';
yourself.
response
document: document;
doNotCache;
yourself.
].

On Aug 3, 2011, at 4:09 PM, Jay Hardesty wrote:


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,
Jay





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Bob Nemec
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh

Thanks Bob - 

I used your suggestion to revamp the Seaside application for my Second-Life-based client, as an example of subclassing WARequestHandler.
Following your example worked perfectly.  

Thanks again,
Jay


On Aug 5, 2011, at 3:55 PM, Bob N. wrote:

We interface with an IVR system by answering VXML. I ended up subclassing WARequestHandler and implemented #handleFiltered: as indicated in the class comments.

Here is a simplified version of the method...
handleFiltered: aRequestContext
| response result request | 
request := aRequestContext request.
result := self processCall: request.
response := aRequestContext response. 
response 
contentType: self contentType; 
nextPutAll: result.
aRequestContext respond.

...where #processCall: answers a VXML string based on the request contents (using #aRequest>>at:ifPresent:)

That, plus a class initialize method...
^WAAdmin register: self at: 'IVR'
...was all that was needed to get started. 

The same image also serves a full Seaside interface for the IVR application. 

Bob Nemec



On Wed, Aug 3, 2011 at 8:01 PM, Jay Hardesty <[hidden email]> wrote:
In fact I assume I really need to push this functionality down to the purely HTTP level.

Situation arose because I've been reusing my Seaside apps to serve data to other sorts of clients as well - overkill I guess since I'm not using any generated html in such cases 


On Aug 4, 2011, at 1:53 AM, Jay Hardesty wrote:

Thank you for the response, James.   

For me, the problem is that I need the XML to be processed automatically (with no dialog).

Whereas my response from Seaside used to return XML - that is something starting with:
<?xml version="1.0" encoding="UTF-8"?...  (because that's how my xmlString starts)

I instead now see something starting:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

For instance the response returned from the code fragment in your response ultimately arrives as the same (html) result 

I should mention that this particular request is being sent to my Seaside app from a non-Seaside client; perhaps a Seaside app simply can't be used in such a way anymore(?)  

Thanks again,
Jay


On Aug 4, 2011, at 1:27 AM, James Foster wrote:

Jay,

With the following code, clicking on a link will open a dialog asking what application to use to open the document or offering to save the document. This looks close to what you are doing. (I'm using Seaside 3.0.5 in GemStone/S.)

James

self requestContext respond: [:response |
| document |
document := myXmlString seasideMimeDocument
mimeType: (WAFileLibrary mimetypeFor: 'xml');
fileName: 'myNewFile.xml';
yourself.
response
document: document;
doNotCache;
yourself.
].

On Aug 3, 2011, at 4:09 PM, Jay Hardesty wrote:


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,
Jay





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh
In reply to this post by Philippe Marschall

On Aug 5, 2011, at 8:01 AM, Philippe Marschall wrote:

> 2011/8/4 Jay Hardesty <[hidden email]>:
>>
>> On Aug 4, 2011, at 8:04 AM, Philippe Marschall wrote:
>>
>>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>>
>>>> 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
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>> Thank you Phillipe - Yes, your code works for me just as you described.
>>
>> I guess my problem is that I want my renderContentOn: to immediately return XML in certain circumstances without any user action.  As in this variation on your code example:
>>
>>        renderContentOn: html
>>                self requestContext respond: [ :response |
>>                        response
>>                                contentType: 'text/xml';
>>                                nextPutAll: '<?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ]
>
> That doesn't work. Components are made to generate HTML and in this
> case a lot of HTML (<DOCTYPE>, <head>, <body>, …) has already been
> generated. You have two options. First you can configure your
> components to generate XML. See Seaside-WebServices-Core and
> Seaside-Tests-WebServices in the addons repository [1] for examples.
> However unless you need #call: and callbacks and friends I found
> recommend to use Seaside-REST, also from the addons repository. There
> is a short overview on the wiki [2] and you can find some examples
> here [3].
>
>
>> If I call this from Firefox, then instead of XML (as in your example) I see
>>        "XML Parsing Error: XML or text declaration not at start of entity[...]"
>> and viewing the page source gives:
>>        "<!DOCTYPE html PUBLIC [...]"
>>
>>
>> Whereas my old code:
>>
>>        renderContentOn: html
>>                self session returnResponse:
>>                        (WAResponse new
>>                                contentType: 'text/xml';
>>                                nextPutAll: <?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ;
>>                                yourself)
>>
>> returned and displayed XML just as your example, but without any user action
>>
>> So what I'm apparently missing is whatever magic happens as a result of the anchor callback being fired in your example.  I wonder if there's any way to get that kind of callback behavior programatically(?)
>>
>>
>>> What do you mean with non-Seaside client? Is it a non-browser
>>> application, non-HTML application? I
>>
>>
>> Yes, I'm using Seaside apps to serve (music score data) to
>> - Seaside web client
>> - Flash web client
>> - iPhone app
>> - code running in Second Life
>> - Croquet environment
>>
>>> In those cases you can still use
>>> Seaside. You can either directly write RequestHandlers or you can have
>>> a look at Seaside-REST.
>>
>> Interesting - I'll try to find an example using WARequestHandler, though I suppose this will mean moving the functionality out of my Seaside app (WAComponent subclass)...
>
> Yes. You can look at WAFileHandler for a complicated examples, for
> simple ones look at Seaside-Benchmark in the addons repository [1].
>
>> Thanks very much for the tips, and for your example which has helped me narrow the scope of the problem
>>
>
> [1] http://www.squeaksource.com/Seaside30Addons
> [2] http://code.google.com/p/seaside/wiki/SeasideRest
> [3] http://www.squeaksource.com/orion
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


Among the possibilities you listed, I ended up subclassing WAXmlComponent to return XML programmatically, roughly as follows:

        renderContentOn: xml
                | query |
                query := initialRequest fields keys first.

                query = 'getAvailableScores' ifTrue: [
                        | anXMLDocument block |
                        anXMLDocument := self class availableScoresAsXML.
                        block := [:element |
                                | tag |
                                tag := xml tag: element name.
                                element attributes keysAndValuesDo: [:name :value |
                                        tag attributeAt: name put: value].
                                        tag with: [element elements do: [:each |
                                                block value: each]]].
                        block value: anXMLDocument elements first].


...that is, building the tags for the WAXmlCanvas from an instance of XMLDocument.  This restores the functionality I had lost going to 3.0.

Thank you once more for all your help!

Jay





_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh

On Aug 6, 2011, at 7:31 PM, Jay Hardesty wrote:

>
> On Aug 5, 2011, at 8:01 AM, Philippe Marschall wrote:
>
>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>
>>> On Aug 4, 2011, at 8:04 AM, Philippe Marschall wrote:
>>>
>>>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>>>
>>>>> 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
>>>> _______________________________________________
>>>> seaside mailing list
>>>> [hidden email]
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>> Thank you Phillipe - Yes, your code works for me just as you described.
>>>
>>> I guess my problem is that I want my renderContentOn: to immediately return XML in certain circumstances without any user action.  As in this variation on your code example:
>>>
>>>       renderContentOn: html
>>>               self requestContext respond: [ :response |
>>>                       response
>>>                               contentType: 'text/xml';
>>>                               nextPutAll: '<?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ]
>>
>> That doesn't work. Components are made to generate HTML and in this
>> case a lot of HTML (<DOCTYPE>, <head>, <body>, …) has already been
>> generated. You have two options. First you can configure your
>> components to generate XML. See Seaside-WebServices-Core and
>> Seaside-Tests-WebServices in the addons repository [1] for examples.
>> However unless you need #call: and callbacks and friends I found
>> recommend to use Seaside-REST, also from the addons repository. There
>> is a short overview on the wiki [2] and you can find some examples
>> here [3].
>>
>>
>>> If I call this from Firefox, then instead of XML (as in your example) I see
>>>       "XML Parsing Error: XML or text declaration not at start of entity[...]"
>>> and viewing the page source gives:
>>>       "<!DOCTYPE html PUBLIC [...]"
>>>
>>>
>>> Whereas my old code:
>>>
>>>       renderContentOn: html
>>>               self session returnResponse:
>>>                       (WAResponse new
>>>                               contentType: 'text/xml';
>>>                               nextPutAll: <?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ;
>>>                               yourself)
>>>
>>> returned and displayed XML just as your example, but without any user action
>>>
>>> So what I'm apparently missing is whatever magic happens as a result of the anchor callback being fired in your example.  I wonder if there's any way to get that kind of callback behavior programatically(?)
>>>
>>>
>>>> What do you mean with non-Seaside client? Is it a non-browser
>>>> application, non-HTML application? I
>>>
>>>
>>> Yes, I'm using Seaside apps to serve (music score data) to
>>> - Seaside web client
>>> - Flash web client
>>> - iPhone app
>>> - code running in Second Life
>>> - Croquet environment
>>>
>>>> In those cases you can still use
>>>> Seaside. You can either directly write RequestHandlers or you can have
>>>> a look at Seaside-REST.
>>>
>>> Interesting - I'll try to find an example using WARequestHandler, though I suppose this will mean moving the functionality out of my Seaside app (WAComponent subclass)...
>>
>> Yes. You can look at WAFileHandler for a complicated examples, for
>> simple ones look at Seaside-Benchmark in the addons repository [1].
>>
>>> Thanks very much for the tips, and for your example which has helped me narrow the scope of the problem
>>>
>>
>> [1] http://www.squeaksource.com/Seaside30Addons
>> [2] http://code.google.com/p/seaside/wiki/SeasideRest
>> [3] http://www.squeaksource.com/orion
>>
>> Cheers
>> Philippe
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> Among the possibilities you listed, I ended up subclassing WAXmlComponent to return XML programmatically, roughly as follows:
>
> renderContentOn: xml
> | query |
> query := initialRequest fields keys first.
>
> query = 'getAvailableScores' ifTrue: [
> | anXMLDocument block |
> anXMLDocument := self class availableScoresAsXML.
> block := [:element |
> | tag |
> tag := xml tag: element name.
> element attributes keysAndValuesDo: [:name :value |
> tag attributeAt: name put: value].
> tag with: [element elements do: [:each |
> block value: each]]].
> block value: anXMLDocument elements first].
>
>
> ...that is, building the tags for the WAXmlCanvas from an instance of XMLDocument.  This restores the functionality I had lost going to 3.0.

should note that in my case the ultimate values in my XMLDocument instance exist as attributes in the leaf nodes - tagged values would require just a little more code to generate the appropriate WAXmlCanvas tags


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

Philippe Marschall
In reply to this post by jayh
2011/8/6 Jay Hardesty <[hidden email]>:

>
> On Aug 5, 2011, at 8:01 AM, Philippe Marschall wrote:
>
>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>
>>> On Aug 4, 2011, at 8:04 AM, Philippe Marschall wrote:
>>>
>>>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>>>
>>>>> 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
>>>> _______________________________________________
>>>> seaside mailing list
>>>> [hidden email]
>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>>>
>>> Thank you Phillipe - Yes, your code works for me just as you described.
>>>
>>> I guess my problem is that I want my renderContentOn: to immediately return XML in certain circumstances without any user action.  As in this variation on your code example:
>>>
>>>        renderContentOn: html
>>>                self requestContext respond: [ :response |
>>>                        response
>>>                                contentType: 'text/xml';
>>>                                nextPutAll: '<?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ]
>>
>> That doesn't work. Components are made to generate HTML and in this
>> case a lot of HTML (<DOCTYPE>, <head>, <body>, …) has already been
>> generated. You have two options. First you can configure your
>> components to generate XML. See Seaside-WebServices-Core and
>> Seaside-Tests-WebServices in the addons repository [1] for examples.
>> However unless you need #call: and callbacks and friends I found
>> recommend to use Seaside-REST, also from the addons repository. There
>> is a short overview on the wiki [2] and you can find some examples
>> here [3].
>>
>>
>>> If I call this from Firefox, then instead of XML (as in your example) I see
>>>        "XML Parsing Error: XML or text declaration not at start of entity[...]"
>>> and viewing the page source gives:
>>>        "<!DOCTYPE html PUBLIC [...]"
>>>
>>>
>>> Whereas my old code:
>>>
>>>        renderContentOn: html
>>>                self session returnResponse:
>>>                        (WAResponse new
>>>                                contentType: 'text/xml';
>>>                                nextPutAll: <?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ;
>>>                                yourself)
>>>
>>> returned and displayed XML just as your example, but without any user action
>>>
>>> So what I'm apparently missing is whatever magic happens as a result of the anchor callback being fired in your example.  I wonder if there's any way to get that kind of callback behavior programatically(?)
>>>
>>>
>>>> What do you mean with non-Seaside client? Is it a non-browser
>>>> application, non-HTML application? I
>>>
>>>
>>> Yes, I'm using Seaside apps to serve (music score data) to
>>> - Seaside web client
>>> - Flash web client
>>> - iPhone app
>>> - code running in Second Life
>>> - Croquet environment
>>>
>>>> In those cases you can still use
>>>> Seaside. You can either directly write RequestHandlers or you can have
>>>> a look at Seaside-REST.
>>>
>>> Interesting - I'll try to find an example using WARequestHandler, though I suppose this will mean moving the functionality out of my Seaside app (WAComponent subclass)...
>>
>> Yes. You can look at WAFileHandler for a complicated examples, for
>> simple ones look at Seaside-Benchmark in the addons repository [1].
>>
>>> Thanks very much for the tips, and for your example which has helped me narrow the scope of the problem
>>>
>>
>> [1] http://www.squeaksource.com/Seaside30Addons
>> [2] http://code.google.com/p/seaside/wiki/SeasideRest
>> [3] http://www.squeaksource.com/orion
>>
>> Cheers
>> Philippe
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> Among the possibilities you listed, I ended up subclassing WAXmlComponent to return XML programmatically, roughly as follows:
>
>        renderContentOn: xml
>                | query |
>                query := initialRequest fields keys first.

Where is initialRequest coming from? Do you set that in
#initialiRequest:? If so it's better to replace it with
self requestContext request

>                query = 'getAvailableScores' ifTrue: [

That's  quite brittle, something like this should be more reliable

self requestContext request includesKey: 'getAvailableScores'

>                        | anXMLDocument block |
>                        anXMLDocument := self class availableScoresAsXML.
>                        block := [:element |
>                                | tag |
>                                tag := xml tag: element name.
>                                element attributes keysAndValuesDo: [:name :value |
>                                        tag attributeAt: name put: value].
>                                        tag with: [element elements do: [:each |
>                                                block value: each]]].
>                        block value: anXMLDocument elements first].
>
>
> ...that is, building the tags for the WAXmlCanvas from an instance of XMLDocument.  This restores the functionality I had lost going to 3.0.
>
> Thank you once more for all your help!


Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAResponse and XML

jayh

On Aug 6, 2011, at 8:09 PM, Philippe Marschall wrote:

> 2011/8/6 Jay Hardesty <[hidden email]>:
>>
>> On Aug 5, 2011, at 8:01 AM, Philippe Marschall wrote:
>>
>>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>>
>>>> On Aug 4, 2011, at 8:04 AM, Philippe Marschall wrote:
>>>>
>>>>> 2011/8/4 Jay Hardesty <[hidden email]>:
>>>>>>
>>>>>> 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
>>>>> _______________________________________________
>>>>> seaside mailing list
>>>>> [hidden email]
>>>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>>
>>>>
>>>> Thank you Phillipe - Yes, your code works for me just as you described.
>>>>
>>>> I guess my problem is that I want my renderContentOn: to immediately return XML in certain circumstances without any user action.  As in this variation on your code example:
>>>>
>>>>        renderContentOn: html
>>>>                self requestContext respond: [ :response |
>>>>                        response
>>>>                                contentType: 'text/xml';
>>>>                                nextPutAll: '<?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ]
>>>
>>> That doesn't work. Components are made to generate HTML and in this
>>> case a lot of HTML (<DOCTYPE>, <head>, <body>, …) has already been
>>> generated. You have two options. First you can configure your
>>> components to generate XML. See Seaside-WebServices-Core and
>>> Seaside-Tests-WebServices in the addons repository [1] for examples.
>>> However unless you need #call: and callbacks and friends I found
>>> recommend to use Seaside-REST, also from the addons repository. There
>>> is a short overview on the wiki [2] and you can find some examples
>>> here [3].
>>>
>>>
>>>> If I call this from Firefox, then instead of XML (as in your example) I see
>>>>        "XML Parsing Error: XML or text declaration not at start of entity[...]"
>>>> and viewing the page source gives:
>>>>        "<!DOCTYPE html PUBLIC [...]"
>>>>
>>>>
>>>> Whereas my old code:
>>>>
>>>>        renderContentOn: html
>>>>                self session returnResponse:
>>>>                        (WAResponse new
>>>>                                contentType: 'text/xml';
>>>>                                nextPutAll: <?xml version="1.0" encoding="UTF-8"?><hello><world/></hello>' ;
>>>>                                yourself)
>>>>
>>>> returned and displayed XML just as your example, but without any user action
>>>>
>>>> So what I'm apparently missing is whatever magic happens as a result of the anchor callback being fired in your example.  I wonder if there's any way to get that kind of callback behavior programatically(?)
>>>>
>>>>
>>>>> What do you mean with non-Seaside client? Is it a non-browser
>>>>> application, non-HTML application? I
>>>>
>>>>
>>>> Yes, I'm using Seaside apps to serve (music score data) to
>>>> - Seaside web client
>>>> - Flash web client
>>>> - iPhone app
>>>> - code running in Second Life
>>>> - Croquet environment
>>>>
>>>>> In those cases you can still use
>>>>> Seaside. You can either directly write RequestHandlers or you can have
>>>>> a look at Seaside-REST.
>>>>
>>>> Interesting - I'll try to find an example using WARequestHandler, though I suppose this will mean moving the functionality out of my Seaside app (WAComponent subclass)...
>>>
>>> Yes. You can look at WAFileHandler for a complicated examples, for
>>> simple ones look at Seaside-Benchmark in the addons repository [1].
>>>
>>>> Thanks very much for the tips, and for your example which has helped me narrow the scope of the problem
>>>>
>>>
>>> [1] http://www.squeaksource.com/Seaside30Addons
>>> [2] http://code.google.com/p/seaside/wiki/SeasideRest
>>> [3] http://www.squeaksource.com/orion
>>>
>>> Cheers
>>> Philippe
>>> _______________________________________________
>>> seaside mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>> Among the possibilities you listed, I ended up subclassing WAXmlComponent to return XML programmatically, roughly as follows:
>>
>>        renderContentOn: xml
>>                | query |
>>                query := initialRequest fields keys first.
>
> Where is initialRequest coming from? Do you set that in
> #initialiRequest:?

Yes, exactly.


> If so it's better to replace it with
> self requestContext request
>
>>                query = 'getAvailableScores' ifTrue: [
>
> That's  quite brittle, something like this should be more reliable
>
> self requestContext request includesKey: 'getAvailableScores'


Super -    yes, Bob N. mentioned that pattern in his reply as well  

(was pretty sure my line of code couldn't possibly point to the intended API)

Thanks as always
Jay


>
>>                        | anXMLDocument block |
>>                        anXMLDocument := self class availableScoresAsXML.
>>                        block := [:element |
>>                                | tag |
>>                                tag := xml tag: element name.
>>                                element attributes keysAndValuesDo: [:name :value |
>>                                        tag attributeAt: name put: value].
>>                                        tag with: [element elements do: [:each |
>>                                                block value: each]]].
>>                        block value: anXMLDocument elements first].
>>
>>
>> ...that is, building the tags for the WAXmlCanvas from an instance of XMLDocument.  This restores the functionality I had lost going to 3.0.
>>
>> Thank you once more for all your help!
>
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside