// отправка XML-файла на сервер

ользую приведенный ниже код для выполнения запроса HTTP POST. PostData находится в форме строки

Образец PostData:

urn: marlin: широкая полоса: 1-1: служба регистрации: li nkAquisitionurn: marlin: организатор: testpdc: devi ce-maker-x: клиент tnemo: aa08a1: 59e a7e8cfa7a8582http: //docs.oasi s-open. org / wss / 2 004/01 / oasis-200 401-wss-wssecuri ty-utility-1.0.x sd "URI =" urn: mar lin: ядро: 1.0: nem o: протокол: профиль: 1 "wsu: Id = "si gid0003" nemosec: Usage = "http: // n emo.intertrust.c om / 2005/10 / security / profile" /> </ SOAP-ENV: Envelo pe>

Мы ожидаем ответ xml / soap, вместо этого мы получаем файл xml в качестве ответа. Может кто-нибудь сказать мне, если процедура для выполнения HTTP POST является правильным (как в приведенном ниже коде)

Примечание: те же самые postData при использовании с cuRL для выполнения POST работают нормально.

public byte [] sendRecv(String PostData, long postDataSize){

  try{
   if(!(PostData.equals("empty"))){
    isPost = true;
    //InputStream postDataInputStream = new ByteArrayInputStream(postData);
    //BasicHttpEntity httpPostEntity = new BasicHttpEntity();
    //httpPostEntity.setContent(postDataInputStream);
    StringEntity httpPostEntity = new StringEntity(PostData, HTTP.UTF_8);
    //httpPostEntity.setContentLength(postData.length);
    //httpPostEntity.setContentType("application/x-www-form-urlencoded");
    httpPost.setEntity(httpPostEntity);
    httpPost.setHeader("Content-Length", new Integer(PostData.length()).toString());
    httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
    httpPost.setHeader("Expect", "100-continue");

   }
  }catch(Exception e) {
   e.printStackTrace();
  }

  try {
   if(isPost == true){
    response = mAndroidHttpClient.execute(httpPost);
    isPost = false;
   }
   else {
    response = mAndroidHttpClient.execute(httpGet);
   }
   statusCode = response.getStatusLine().getStatusCode();

   if(statusCode != 200 ){
    if(statusCode == 404) {
     //System.out.println("error in http connection : 404");

     //return ERR_HTTP_NOTFOUND 
    } else if(statusCode == 500){
     //System.out.println("error in http connection : 500");
     //return ERR_HTTP_INTERNALSEVERERROR
    } else {
     //System.out.println("error in http connection : error unknown");
     //return ERR_HTTP_FATAL
    }
   }

   HttpEntity entity = response.getEntity();
   InputStream is = entity.getContent();

   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   for (int next = is.read(); next != ENDOFSTREAM; next = is.read()) {
    bos.write(next);
   }
   responseBuffer = bos.toByteArray();
   bos.flush();
   bos.close();

   }catch (IOException e) {
    e.printStackTrace();
    }

   return responseBuffer;
 }  

Ответы на вопрос(2)

Ваш ответ на вопрос