• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

post xml doc over HTTP -- web service

Hi,
I need parse a queryString(key1=val1&key2=val2&key3=val3) into and xml doc and POST the xml doc over HTTP.
First time doing this. can somone give implementation ideas.

0
komlaaa
Asked:
komlaaa
2 Solutions
 
komlaaaAuthor Commented:
Is this imposible or no idea at the moment?
0
 
a122178Commented:
Yes.  Create a servlet class.

Accept the URL request with the parameter. Then you can response back over HTTP by

public void queryString() extends HttpServlet() {

response.setContentType("text/xml");

PrintWriter out = response.getWriter();

out.print("<?xml version='1.0' encoding='ISO-8859-1'?>");
out.print("<Keys>");
out.print("<Key1>val1</Key1>");
out.print("<Key2>val2</Key2>");
out.print("</Keys>");

}

Somthing like that.

:)
0
 
Tol_cvCommented:

    String xmlText = ...         // here your xml
    HttpURLConnection c = ...       // URl where you want to send..
    c.setRequestMethod("POST");
    c.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
    c.setDoOutput(true);
    OutputStreamWriter out = new OutputStreamWriter(c.getOutputStream(),
"UTF8");
    out.write(xmlText);
    out.close();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now