【发布时间】:2015-04-22 16:12:37
【问题描述】:
我需要使用 URL 参数和 XML 向以下 URL 发出 http post 请求。我正在尝试使用下面的代码,但无法得到正确的响应。
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);
}
【问题讨论】:
标签: java http-post httpclient apache-httpclient-4.x