Author: keith
Date: Thu Jul 10 07:55:52 2008
New Revision: 19103
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19103

Log:
Fixing Mashup-920. Using commons HTTPClient to get the WSDL instead of 
URLConnection so that we can set the Keystore into it


Modified:
   
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java

Modified: 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java?rev=19103&r1=19102&r2=19103&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
      (original)
+++ 
trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
      Thu Jul 10 07:55:52 2008
@@ -43,6 +43,9 @@
 import org.apache.commons.httpclient.cookie.CookiePolicy;
 import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
 import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyEngine;
 import org.apache.rampart.RampartMessageData;
@@ -83,11 +86,9 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.StringReader;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -427,9 +428,16 @@
                 throw Context.reportRuntimeError("INVALID_SYNTAX_EXCEPTION");
         }
 
+        HttpMethod method = new GetMethod();
         try {
-            InputStream in = (new 
URL(wsdlURL)).openConnection().getInputStream();
-                       Document doc = XMLUtils.newDocument(in);
+            URL url = new URL(wsdlURL);
+            int statusCode = MashupUtils.executeHTTPMethod(method, url);
+            if (statusCode != HttpStatus.SC_OK) {
+                    throw new MashupFault(
+                            "An error occured while getting the resource at " 
+ url +
+                                    ". Reason :" + method.getStatusLine());
+            }
+                       Document doc = 
XMLUtils.newDocument(method.getResponseBodyAsStream());
                        WSDLReader reader = 
WSDLFactory.newInstance().newWSDLReader();
                        reader.setFeature("javax.wsdl.importDocuments", true);
                        Definition definition = 
reader.readWSDL(getBaseURI(wsdlURL), doc);
@@ -559,6 +567,9 @@
                 throw new MashupFault(e);
             } catch (Exception e) {
                 throw new MashupFault(e);
+            } finally {
+                // Release the connection.
+                method.releaseConnection();
             }
         setCommonProperties(cx, wsRequest);
         wsRequest.wsdlMode = true;

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to