< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/client/p2p/HttpSOAPConnection.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 495                     value = httpConnection.getHeaderField(i);
 496 
 497                     if (key == null && value == null)
 498                         break;
 499 
 500                     if (key != null) {
 501                         StringTokenizer values =
 502                             new StringTokenizer(value, ",");
 503                         while (values.hasMoreTokens())
 504                             headers.addHeader(key, values.nextToken().trim());
 505                     }
 506                     i++;
 507                 }
 508 
 509                 httpIn =
 510                         (isFailure
 511                         ? httpConnection.getErrorStream()
 512                         : httpConnection.getInputStream());
 513                 // If no reply message is returned,
 514                 // content-Length header field value is expected to be zero.
 515                 // InputStream#available() can't be used here - it just says no data *YET*!



 516                 if ((httpIn == null )
 517                         || (httpConnection.getContentLength() == 0)) {

 518                     response = null;
 519                     log.warning("SAAJ0014.p2p.content.zero");
 520                 } else {
 521                     response = messageFactory.createMessage(headers, httpIn);
 522                 }
 523 
 524             } catch (SOAPException ex) {
 525                 throw ex;
 526             } catch (Exception ex) {
 527                 log.log(Level.SEVERE,
 528                         "SAAJ0010.p2p.cannot.read.resp",
 529                         ex);
 530                 throw new SOAPExceptionImpl(
 531                     "Unable to read response: " + ex.getMessage());
 532             } finally {
 533                if (httpIn != null)
 534                    httpIn.close();
 535                httpConnection.disconnect();
 536             }
 537         }


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 495                     value = httpConnection.getHeaderField(i);
 496 
 497                     if (key == null && value == null)
 498                         break;
 499 
 500                     if (key != null) {
 501                         StringTokenizer values =
 502                             new StringTokenizer(value, ",");
 503                         while (values.hasMoreTokens())
 504                             headers.addHeader(key, values.nextToken().trim());
 505                     }
 506                     i++;
 507                 }
 508 
 509                 httpIn =
 510                         (isFailure
 511                         ? httpConnection.getErrorStream()
 512                         : httpConnection.getInputStream());
 513                 // If no reply message is returned,
 514                 // content-Length header field value is expected to be zero.
 515                 // java SE 6 documentation says :
 516                 // available() : an estimate of the number of bytes that can be read
 517                 //(or skipped over) from this input stream without blocking
 518                 //or 0 when it reaches the end of the input stream.
 519                 if ((httpIn == null )
 520                         || (httpConnection.getContentLength() == 0)
 521                         || (httpIn.available() == 0)) {
 522                     response = null;
 523                     log.warning("SAAJ0014.p2p.content.zero");
 524                 } else {
 525                     response = messageFactory.createMessage(headers, httpIn);
 526                 }
 527 
 528             } catch (SOAPException ex) {
 529                 throw ex;
 530             } catch (Exception ex) {
 531                 log.log(Level.SEVERE,
 532                         "SAAJ0010.p2p.cannot.read.resp",
 533                         ex);
 534                 throw new SOAPExceptionImpl(
 535                     "Unable to read response: " + ex.getMessage());
 536             } finally {
 537                if (httpIn != null)
 538                    httpIn.close();
 539                httpConnection.disconnect();
 540             }
 541         }


< prev index next >