3

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;

関連記事: IIS 側で作業している同僚が、MSDNに WCF コードを投稿しました。

4

0 に答える 0