You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/02/28 22:50:24 UTC

svn commit: r512996 - /webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java

Author: danj
Date: Wed Feb 28 13:50:23 2007
New Revision: 512996

URL: http://svn.apache.org/viewvc?view=rev&rev=512996
Log:
Added check to SimpleSoapClient.send() so that we only use HttpURLConnection.getInputStream() if 
we got a HTTP 200 OK. Otherwise, we use getErrorStream(). This will prevent us from dropping 
the real SOAPFault content when an IOException is thrown for using getInputStream() on error content.

Modified:
    webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java

Modified: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java?view=diff&rev=512996&r1=512995&r2=512996
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SimpleSoapClient.java Wed Feb 28 13:50:23 2007
@@ -267,21 +267,34 @@
             output.flush();
             output.close();
             
+            int responseCode = connection.getResponseCode();
+            InputStream response = null;
+            
             //
-            // read in the response and build an XML document from it
+            // only use getInputStream() if we got HTTP 200 OK
             //
-            InputStream input = connection.getInputStream();
+            if (responseCode == HttpURLConnection.HTTP_OK)
+                response = connection.getInputStream();
             
-            Document responseDoc = XmlUtils.createDocument(input);
+            else
+                response = connection.getErrorStream();
+
+            //
+            // read in the response and build an XML document from it
+            //
+            Document responseDoc = XmlUtils.createDocument(response);
             soapResponse = XmlUtils.getFirstElement(responseDoc);
             
-            input.close();
+            response.close();
             connection.disconnect();
         }
         
+        //
+        // handle any other runtime/IO exceptions as best we can
+        //
         catch (Throwable error)
         {
-            SoapFault soapFault = new SoapFault(error);
+            SoapFault soapFault = new SoapFault(error.getMessage(), error);
             return new Element[]{ soapFault.toXML() };
         }
         



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org