More common is to deal with xml requests though a POST. In that case you can do something like below.

Cheers,
Joost


@Inject
private RequestGlobals requestGlobals;

@OnEvent(value = EventConstants.ACTIVATE)
private Object activate() throws Exception {

HttpServletRequest httpServletRequest = requestGlobals.getHTTPServletRequest(); ServletInputStream inputStream = httpServletRequest.getInputStream();

        SAXBuilder builder = new SAXBuilder();
        Document xmlRequest = builder.build(inputStream);

        String xmlStringResponse = .... build up your xml response ....

final ByteArrayInputStream output = new ByteArrayInputStream(xmlStringResponse);

        final StreamResponse streamResponse = new StreamResponse() {

            public String getContentType() {
                return "text/xml";
            }

            public InputStream getStream() throws IOException {
                return output;
            }

            public void prepareResponse(Response response) {
            }
        };
        return streamResponse;
}

On 15/11/10 4:47 PM, niksami wrote:
This will work for me. Basically I need to receive XML as a parameter, for
example as a String in onActivate() method. So, I think this will do job for
me:

  public TextStreamResponse onActivate(String xml) {

     //doing something with xml

     return new TextStreamResponse("text/xml", xml);

}

Thank you!

Niksa


Richard Hill-7 wrote:

You don't specify where/how you want to receive XML requests from - is
this server-to-server? If so this out of the realm of Tapestry, but
there's plenty of java networking libs to help you do this.

With respect to sending an xml document/page to a browser client,
tapestry is not really designed for this. Although you could use
TextStreamResponse for this:

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/util/TextStreamResponse.html


public TextStreamResponse onActivate() {

     String xml = getMyXMLFromSomeWhere....

     return new TextStreamResponse("text/xml", xml);

}


R.



-----Original Message-----
From: niksami<ni...@fleka.me>
Reply-to: "Tapestry users"<users@tapestry.apache.org>
To: users@tapestry.apache.org
Subject: XML requests
Date: Mon, 15 Nov 2010 06:18:03 -0800 (PST)

Hello everyone.

In my application I need to receive XML requests, and then to send the
response back to the client in XML format too. I tried to find some nice
solution here, but with no success. I hope you can give me some short code
examples.

Best regards,
Niksa



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to