解决方案 »

  1.   

    可能是return的位置有问题?试试先在try外边new一个InputStream对象,赋null,然后在if语句里再调用response.getEntity().getContent()来给InputStream对象赋值,整个try catch结束后再return这个对象。
      

  2.   

        /我把这句去掉就好了··    // 200
                if (response.getStatusLine().getStatusCode() == 200) { 是不是response.getStatusLine().getStatusCode()也会消耗掉content
      

  3.   


    把代码改成这样也可以
     public InputStream sendXml(String uri, String xml) {
    post = new HttpPost(uri);
    InputStream is = null;
    try {
    StringEntity entity = new StringEntity(xml, ConstantValue.ENCODING);
    post.setEntity(entity); HttpResponse response = client.execute(post); // // 200
    // is = response.getEntity().getContent(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
    HttpEntity entitys = response.getEntity();
    if (entitys != null) {
    is = entity.getContent();
    }
    }
    } catch (Exception e) {
    e.printStackTrace();
    } return is; }
      

  4.   

        /我把这句去掉就好了··    // 200
                if (response.getStatusLine().getStatusCode() == 200) { 是不是response.getStatusLine().getStatusCode()也会消耗掉content好吧,问题解决了就好。。结贴吧。。
      

  5.   


    把代码改成这样也可以
     public InputStream sendXml(String uri, String xml) {
    post = new HttpPost(uri);
    InputStream is = null;
    try {
    StringEntity entity = new StringEntity(xml, ConstantValue.ENCODING);
    post.setEntity(entity); HttpResponse response = client.execute(post); // // 200
    // is = response.getEntity().getContent(); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
    HttpEntity entitys = response.getEntity();
    if (entitys != null) {
    is = entity.getContent();
    }
    }
    } catch (Exception e) {
    e.printStackTrace();
    } return is; }那就是说明response.getEntity();返回的是null啊,导致的报异常。