The code snippet below uses JDOM but should easily be adaptable to
anything else. Hope it helps. On the server side read the data from the
request's inputStream. If however you want to use multipart messages
things get slightly more tricky.
URLConnection conn = ...
// configure the connection
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
// output the document into a byte array output stream
ByteArrayOutputStream outputStream = new
ByteArrayOutputStream();
PrintWriter outputWriter = new PrintWriter(outputStream, true);
XMLOutputter outputter = new XMLOutputter(" ", true,
"ISO-8859-1");
outputter.setTextNormalize(true);
outputter.output(requestDocument, outputWriter);
outputWriter.flush();
// set the header fields
conn.setRequestProperty("Content-Type", "text/xml");
conn.setRequestProperty("Content-Length",
String.valueOf(outputStream.size()));
// write the data to the request body
outputStream.writeTo(conn.getOutputStream());
}
Mark Benussi <[EMAIL PROTECTED]> schrieb am 17.09.2004, 10:57:56:
> Has anyone got an example of posting an XML message via the web to a sruts
> action on an external site and how I should handle that request in the
> struts action?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Martin Schaefer
NAXOS Software Solutions GmbH i.G.
Herrenstr. 1
69502 Hemsbach
Germany
Phone:+49 (0) 6201 49298-2
Mobile: +49 (0) 172 6269246
Fax: +49 (0) 6201 49298-1
Mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]