用fiddler发送请求可以获取到参数,但是用httpclient返回500;求解答
(下面是我的部分代码)
ProtocolSocketFactory fcty = new MySecureProtocolSocketFactory();
Protocol.registerProtocol("https", new Protocol("https", fcty, 443));
String response = null;
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(url);
postMethod.getParams().setParameter(
HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
// 设置Post数据
if (!params.isEmpty()) {
String data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><EntityPreMethod><Method>"
+ params.get("Method")
+ "</Method><Parameters>"
+ params.get("Parameters")
+ "</Parameters><AccessId>******</AccessId></EntityPreMethod>";
System.out.println(data);
postMethod.setRequestEntity(new StringRequestEntity(data,
"text/xml", "gbk"));
postMethod.addRequestHeader("Authorization",
"Bearer " + this.getAccessToken());
postMethod.setRequestHeader("Content-Type", "text/xml");
}
try {
int statusCode = client.executeMethod(postMethod);
System.out.println(statusCode);
if (statusCode == HttpStatus.SC_OK) {
response = postMethod.getResponseBodyAsString();