我已经通过使用生成了 Web 服务类wsimport
,现在我应该向这个 Web 服务发送一个 XML 请求(给定的特定格式),它返回一个 XML 响应,然后我可以在我身边使用那个 XML 响应。你如何创建这个我应该发送到 web 服务的自定义 XML 请求。那里有任何可用的文件吗?
问问题
9131 次
1 回答
3
有很多方法可以做到这一点..
其中之一是使用Apache 的 HttpClient并执行这样的 POST
PostMethod post = new PostMethod("http://jakarata.apache.org/");
NameValuePair[] data = {
new NameValuePair("user", "joe"),
new NameValuePair("password", "bloggs")
};
post.setRequestBody(data);
post.setRequestHeader("Content-type", "application/xhtml+xml");
// execute method and handle any error responses.
...
InputStream in = post.getResponseBodyAsStream();
// handle response.
于 2013-10-02T20:34:12.320 回答