From 9c8e8bd77e391dbf7d1cc81ab2d4c6b8d09da0ac Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Wed, 3 Feb 2010 05:07:52 +0000 Subject: [PATCH] added ability to specify a Gson instance for use in getting a response. --- .../gson/webservice/client/WebServiceClient.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java b/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java index 028e0f32..e3cd9d51 100644 --- a/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java +++ b/wsclient/src/main/java/com/google/gson/webservice/client/WebServiceClient.java @@ -61,16 +61,20 @@ public final class WebServiceClient { } public WebServiceResponse getResponse(WebServiceCallSpec callSpec, WebServiceRequest request) { + Gson gson = new GsonBuilder().registerTypeAdapter(ResponseBody.class, + new ResponseBodyGsonConverter(callSpec.getResponseSpec().getBodySpec())) + .create(); + return getResponse(callSpec, request, gson); + } + + public WebServiceResponse getResponse( + WebServiceCallSpec callSpec, WebServiceRequest request, Gson gson) { try { URL webServiceUrl = getWebServiceUrl(callSpec); if (logger != null) { logger.log(logLevel, "Opening connection to " + webServiceUrl); } HttpURLConnection conn = (HttpURLConnection) webServiceUrl.openConnection(); - Gson gson = new GsonBuilder() - .registerTypeAdapter(ResponseBody.class, - new ResponseBodyGsonConverter(callSpec.getResponseSpec().getBodySpec())) - .create(); RequestSender requestSender = new RequestSender(gson, logLevel); requestSender.send(conn, request); ResponseReceiver responseReceiver =