Sending XML as a MIME type over HTTP
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, November 4, 2003 04:36 PM

I am sending XML to a servlet in the following way: URL url = new URL("http://203.103.137.67/interface_test/xml"); URL url = new URL("http://localhost:81/xml"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); OutputStream out = conn.getOutputStream(); PrintWriter out = new PrintWriter(new FileWriter("c:\out.xml", false)); XMLSerializer ser = new XMLSerializer(out, new OutputFormat("xml", "UTF-8", false)); // creating DOM document to send and serialize it XmlWrapper xml = new XmlWrapper(   More>>

I am sending XML to a servlet in the following way:


URL url = new URL("http://203.103.137.67/interface_test/xml");

URL url = new URL("http://localhost:81/xml");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setDoInput(true);

conn.setDoOutput(true);

OutputStream out = conn.getOutputStream();

PrintWriter out = new PrintWriter(new FileWriter("c:\out.xml", false));

XMLSerializer ser = new XMLSerializer(out, new OutputFormat("xml", "UTF-8", false));


// creating DOM document to send and serialize it
XmlWrapper xml = new XmlWrapper();

xml.setFilename("c:\test.xml");

doc = xml.getDocument();

ser.serialize(doc);

out.close();


// getting response XML from host into a DOM document
DOMParser parser = new DOMParser();

conn.getInputStream();

parser.parse(new InputSource(conn.getInputStream()));




The receiving servlet can read it fine as XML, but i'm not sure if I am sending it as a multipart mime type.

The receiving server need to receive XML messages in this way:


content-type: multipart/related;
boundary="MIME_boundary"


This is a multi-part message in MIME format.



--MIME_boundary

content-type: text/xml; charset="us-ascii"

content-transfer-encoding: 7bit



... ...



--MIME_boundary

content-type: text/xml; charset="us-ascii"

content-transfer-encoding: 7bit

Content-ID: <0@Joe>



... ...



--MIME_boundary--




How do I send as a MIME type rather than just XML? And how would I receive XML sent as multipart MIMEs too?

   <<Less
About | Sitemap | Contact