IIS 7.5处理RESTful POST的方式与其他服务器不同

时间:2013-05-29 17:19:44

标签: wcf http rest iis iis-7.5

我对IIS 7.5服务器进行RESTful POST,但它看不到正文:

HttpClient httpclient =  new DefaultHttpClient();     
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = "";

HttpPost httppost = new HttpPost(request.getHost());                        

for(@SuppressWarnings("rawtypes") Header header : request.getHeaders()){
    httppost.setHeader(header.getKey(), header.getValue());
}

if(requestBody.length()>0){
      // append the body data to the post
      StringBuilder sb = new StringBuilder();
      sb.append(requestBody);
      StringEntity stringentity = new StringEntity(sb.toString(), HTTP.UTF_8);
      httppost.setEntity(stringentity);                             
}

// hit the server
response = httpclient.execute(httppost, responseHandler);


// clean up 
httppost = null;

return response;    

它可以看到标题,但永远无法看到正文实体

requestBody只是一个简单的字符串。

使用完全相同的代码,正文和标题,并将此POST指向运行IIS 6.0或Apache Tomcat 7的另一台服务器,两者都可以查看并提取标题和正文而不会出现问题。

什么是IIS 7.5寻找它无法看到身体?我需要以不同的方式制作帖子吗?

参考:

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HTTP;

相关文章: 在MSDN上,我在IIS方面工作的对手有posted his WCF code

0 个答案:

没有答案
相关问题