Do I have to save XML as a file before sending it to DCS?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Do I have to save XML as a file before sending it to DCS?

     I created a domsource of my xml doc, and I am trying to send this to Carrot2 DCS, but it always receive complaint with HTTP code 400 from DCS.  Do I have to save the xml to a file before I can send the xml to DCS?

Following is my code:
     DOMSource reqMsg = new DOMSource(doc);
     URL urlCluster = new URL ("http://localhost:8080/dcs/rest");
      URLConnection urlConnCluster = urlCluster.openConnection ();
      urlConnCluster.setRequestProperty ("Content-Type", "multipart/form-data;charset=\"utf-8\";boundary=\"AaB03x\"");

      OutputStreamWriter outCluster = new OutputStreamWriter(urlConnCluster.getOutputStream());

      TransformerFactory transFactory = TransformerFactory.newInstance();
      Transformer transformer = transFactory.newTransformer();

      transformer.transform (reqMsg, new StreamResult (outCluster));
      outCluster.flush ();
      outCluster.close ();

      transformer.setOutputProperty("indent", "yes");
      StreamResult result = new StreamResult(response.getOutputStream());
      transformer.transform(new StreamSource (urlConnCluster.getInputStream ()), result);