0

I need to make a http post request to the below URL with the URL parameters along with the XML. I am trying with below code and not able to get proper response back.

URL - https://mytest.com?z=123&b=abc&c=%10

xml - <test>
        <data> This is test XML </data>
      </test>

public String getResponse(String xml) {

    HttpClient client = new HttpClient();
    String url="https://mytest.com";
    PostMethod pMethod = new pMethod(url);
    pMethod.addParameter("z","123");
    pMethod.addParameter("b","abc");
    pMethod.addParameter("c","%10");
    post.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF-8"));
    client.executeMethod(pMethod);
}
Shrihastha
  • 71
  • 1
  • 5
  • 16

1 Answers1

0

Please elaborate what kind of response you are expecting? If you are facing problem only in sending xml string to the given URL then may be Send Xml string through POST method in java could help you.

Community
  • 1
  • 1
Nishit Shah
  • 182
  • 1
  • 10
  • I am expecting XML response. Since this is http post request, I want to hide my URL parameters. Along with URL parameters, I need to post the XML. I am not able to do both together (encode URL parameters+ posting the XML). – Shrihastha May 04 '15 at 03:27