changeset 26:c4431f39926a

New method to call a service with a ResponseHandler. http-client/trunk@2279 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 04 Jul 2011 10:17:22 +0000
parents 97628364ab0b
children 73b211b559e2
files ChangeLog src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java
diffstat 3 files changed, 36 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jun 28 07:59:28 2011 +0000
+++ b/ChangeLog	Mon Jul 04 10:17:22 2011 +0000
@@ -1,3 +1,10 @@
+2011-07-04  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java,
+	  src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java:
+	  Added a method to call a service with a ResponseHandler. This allows us
+	  to access the InputStream directly.
+
 2011-06-28  Ingo Weinzierl <ingo@intevation.de>
 
 	Tagged RELEASE 0.4
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Tue Jun 28 07:59:28 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Mon Jul 04 10:17:22 2011 +0000
@@ -59,6 +59,13 @@
      Document callService(String url, String service, Document input)
      throws ConnectionException;
 
+     Object callService(
+         String          url,
+         String          service,
+         Document        input,
+         ResponseHandler handler)
+     throws ConnectionException;
+
 
     /*******************************
      * Collections API
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Tue Jun 28 07:59:28 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Mon Jul 04 10:17:22 2011 +0000
@@ -475,23 +475,33 @@
      public Document callService(String url, String service, Document input)
      throws ConnectionException
      {
-         if (logger.isDebugEnabled()) {
-             logger.debug("Start service call to '" + service + "'");
-         }
-
          DocumentResponseHandler handler = new DocumentResponseHandler();
 
-         try {
-             String serverUrl = url + PATH_SERVICE + "/" + service;
-             return (Document) handler.handle(doPost(serverUrl, input));
-         }
-         catch (IOException ioe) {
-             throw new ConnectionException(
-                     "Connection to server failed: " + ioe.getMessage());
-         }
+         return (Document) callService(url, service, input, handler);
      }
 
 
+     public Object callService(
+         String          url,
+         String          service,
+         Document        input,
+         ResponseHandler handler)
+     throws ConnectionException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Start service call to '" + service + "'");
+        }
+
+        try {
+            String serverUrl = url + PATH_SERVICE + "/" + service;
+            return handler.handle(doPost(serverUrl, input));
+        }
+        catch (IOException ioe) {
+            throw new ConnectionException(
+                "Connection to server failed: " + ioe.getMessage());
+        }
+    }
+
+
     /*******************************
      * Users API
      *******************************/

http://dive4elements.wald.intevation.org