Well, it's fairly straightforward.  Your client opens an HTTP connection to a
handling servlet and posts the XML as a stream of HTTP bytes.  The handling
servlet receives the XML bytes in the doPost() and either parses the received
bytes into an XML document, or simply dumps the stream to a file, and then
optionally returns an XML response back to the client.

XML is just data, so you can transport (serialize) it back and forth across an
HTTP connection, though you'll probably want to to materialize it into objects
at either endpoint.  There are many design, transport, and performance
variations on this theme, but this code is the simplest example that came to
mind.

I'd also recommend reading this article on the use of HTTP as a substrate for
other protocols, as it describes the particulars of using HTTP in relation to
its intended design...

    http://www.ietf.org/internet-drafts/draft-moore-using-http-00.txt

----------

    public void uploadXML(String xmlDocumentText) throws Exception {
        //
        // Open an HTTP connection to the XML handling servlet.
        //
        URL xmlHandlingServlet =
                new URL("http://yourserver/servlet/xmlHandlingServlet");
        URLConnection connection = xmlHandlingServlet.openConnection();
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setUseCaches(false);
        connection.setRequestProperty("Content-Type", "text/xml");
        //
        // Post the XML document text as a stream of bytes.
        //
        DataOutputStream requestXMLStream =
                new DataOutputStream(connection.getOutputStream());
        requestXMLStream.writeBytes(xmlDocumentText);
        requestXMLStream.flush();
        requestXMLStream.close();
        //
        // Handle the response XML.
        //
        InputStream responseXMLStream = connection.getInputStream();
        <do something with the response>
    }

    public void doPost(HttpServletRequest request, HttpServletResponse
response)
        throws ServletException, IOException  {

        //
        // Parse or dump the posted XML bytes using the
        // request.getInputStream()
        //

        //
        // Send an XML response.
        //
        String responseXML = <create an XML response string>
        response.setContentType("text/xml");
        response.setContentLength(responseXML.length());
        PrintWriter writer = response.getWriter();
        writer.write(responseXML);
        writer.flush();
    }


Mike

Howard Lee wrote:

> Thanks Mike. Could you give me more in detail? with some code snippets?
> Again thank you very much Mike.
>
> howard
>
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Mike Clark
> Sent: Friday, August 04, 2000 1:13 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Help! XML intergration!
>
> You could transport the XML in an HTTP request, and then return an XML
> response in the HTTP response.
>
> Mike

Howard Lee wrote:

> Thanks Mike. Could you give me more in detail? with some code snippets?
> Again thank you very much Mike.
>
> howard
>
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Mike Clark
> Sent: Friday, August 04, 2000 1:13 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Help! XML intergration!
>
> You could transport the XML in an HTTP request, and then return an XML
> response in the HTTP response.
>
> Mike
>
> --- Howard Lee <[EMAIL PROTECTED]> wrote:
> > Hi folks,
> >
> > Maybe some of you have done this before and shed some light on me. We
> > have a
> > third party vendor who is working on web pages which basically
> > collect
> > information and turn it into XML and wants to give it to us (they are
> > on a
> > separate web server). Our environment is EJB/JSP/Servlet, and my
> > question is
> > how should I receive that XML file? I thought about them passing me
> > URI of
> > the XML file and from that URI I go grab the XML file, but I thought
> > it
> > could get messy (cleaning up old XML files etc). Any idea how I
> > should
> > approach this? What would be the best approach to this? Thank you
> > very much
> > folks!
> >
> >
> ===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in
> > the body
> > of the message "signoff EJB-INTEREST".  For general help, send email
> > to
> > [EMAIL PROTECTED] and include in the body of the message "help".
> >
> >
> >
> >
>
> __________________________________________________
> Do You Yahoo!?
> Kick off your party with Yahoo! Invites.
> http://invites.yahoo.com/
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

--
//////////////////////////////////////////////////////
//
//  Mike Clark
//
//  Clarkware Consulting
//  Enterprise Java Architecture, Design, Development
//
//  http://www.clarkware.com
//  [EMAIL PROTECTED]
//  +1.720.851.2014
//

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to