[jboss-svn-commits] JBL Code SVN: r29528 - labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Oct 2 09:03:41 EDT 2009
Author: dward
Date: 2009-10-02 09:03:41 -0400 (Fri, 02 Oct 2009)
New Revision: 29528
Modified:
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2855
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2009-10-02 12:29:39 UTC (rev 29527)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2009-10-02 13:03:41 UTC (rev 29528)
@@ -116,7 +116,15 @@
public SOAPProxy(ConfigTree config) throws ConfigurationException
{
payloadProxy = new MessagePayloadProxy(config);
- WSDLDefinitions wsdl_def = SOAPProxyWsdlLoader.loadDefinitions(config);
+ WSDLDefinitions wsdl_def;
+ try
+ {
+ wsdl_def = SOAPProxyWsdlLoader.loadDefinitions(config);
+ }
+ catch (IOException ioe)
+ {
+ throw new ConfigurationException(ioe);
+ }
for ( WSDLBinding wsdl_bind : wsdl_def.getBindings() )
{
for ( WSDLBindingOperation wsdl_bind_oper : wsdl_bind.getOperations() )
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java 2009-10-02 12:29:39 UTC (rev 29527)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java 2009-10-02 13:03:41 UTC (rev 29528)
@@ -19,11 +19,46 @@
*/
package org.jboss.soa.esb.actions.soap.proxy;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.actions.soap.AuthBASICWsdlContractPublisher;
+import org.jboss.soa.esb.helpers.ConfigTree;
/**
- * SOAPProxy WSDL contract publisher.
+ * SOAPProxy wsdl contract publisher.
*
* @author dward at jboss.org
*/
-public class SOAPProxyWsdlContractPublisher extends AuthBASICWsdlContractPublisher {}
+public class SOAPProxyWsdlContractPublisher extends AuthBASICWsdlContractPublisher
+{
+
+ @Override
+ public String getWsdl(String wsdlAddress) throws IOException
+ {
+ ConfigTree config = new ConfigTree("config");
+ Properties props = getActionProperties();
+ for ( Object key : props.keySet() )
+ {
+ String name = (String)key;
+ String value = props.getProperty(name);
+ config.setAttribute(name, value);
+ }
+ SOAPProxyWsdlLoader loader = SOAPProxyWsdlLoader.newLoader(config);
+ InputStream is = null;
+ try
+ {
+ is = new BufferedInputStream( loader.getURL().openStream() );
+ return StreamUtils.readStreamString(is, "UTF-8");
+ }
+ finally
+ {
+ try { if (is != null) is.close(); } catch (Throwable t) {}
+ loader.cleanup();
+ }
+ }
+
+}
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java 2009-10-02 12:29:39 UTC (rev 29527)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java 2009-10-02 13:03:41 UTC (rev 29528)
@@ -32,6 +32,7 @@
import javax.management.ObjectName;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.soap.AuthBASICWsdlContractPublisher;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.util.ClassUtil;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
@@ -50,7 +51,7 @@
public abstract class SOAPProxyWsdlLoader
{
- public abstract URL getWsdlURL() throws MalformedURLException;
+ public abstract URL getURL() throws MalformedURLException;
public void cleanup() {}
@@ -59,45 +60,50 @@
return File.createTempFile(SOAPProxyWsdlLoader.class.getName() + "-", ".wsdl");
}
- public static WSDLDefinitions loadDefinitions(ConfigTree config) throws ConfigurationException
+ public static WSDLDefinitions loadDefinitions(ConfigTree config) throws IOException
{
- String wsdl_location = config.getRequiredAttribute("wsdl");
- SOAPProxyWsdlLoader wsdl_loader;
- if ( wsdl_location.startsWith("http://") || wsdl_location.startsWith("https://") )
+ SOAPProxyWsdlLoader loader = newLoader(config);
+ WSDLDefinitions definitions;
+ try
{
- wsdl_loader = new HttpSOAPProxyWsdlLoader(wsdl_location, config);
+ URL url = loader.getURL();
+ definitions = WSDLDefinitionsFactory.newInstance().parse(url);
}
- else if ( wsdl_location.startsWith("file://") )
+ finally
{
- wsdl_loader = new FileSOAPProxyWsdlLoader( wsdl_location.substring(7, wsdl_location.length()) );
+ loader.cleanup();
}
- else if ( wsdl_location.startsWith("classpath://") )
+ return definitions;
+ }
+
+ public static SOAPProxyWsdlLoader newLoader(ConfigTree config) throws IOException
+ {
+ String address;
+ try
{
- wsdl_loader = new ClasspathSOAPProxyWsdlLoader( wsdl_location.substring(12, wsdl_location.length()) );
+ address = config.getRequiredAttribute("wsdl");
}
- else if ( wsdl_location.startsWith("internal://") )
+ catch (ConfigurationException ce)
{
- wsdl_loader = new InternalSOAPProxyWsdlLoader( wsdl_location.substring(11, wsdl_location.length()) );
+ throw new IOException( ce.getMessage() );
}
- else
+ if ( address.startsWith("http://") || address.startsWith("https://") )
{
- throw new ConfigurationException("unrecognized wsdl location: " + wsdl_location);
+ return new HttpSOAPProxyWsdlLoader(address, config);
}
- WSDLDefinitions wsdl_definitions;
- try
+ else if ( address.startsWith("file://") )
{
- URL wsdl_url = wsdl_loader.getWsdlURL();
- wsdl_definitions = WSDLDefinitionsFactory.newInstance().parse(wsdl_url);
+ return new FileSOAPProxyWsdlLoader( address.substring(7, address.length()) );
}
- catch (MalformedURLException mue)
+ else if ( address.startsWith("classpath://") )
{
- throw new ConfigurationException(mue);
+ return new ClasspathSOAPProxyWsdlLoader( address.substring(12, address.length()) );
}
- finally
+ else if ( address.startsWith("internal://") )
{
- wsdl_loader.cleanup();
+ return new InternalSOAPProxyWsdlLoader( address.substring(11, address.length()) );
}
- return wsdl_definitions;
+ throw new IOException("unrecognized wsdl location: " + address);
}
private static class HttpSOAPProxyWsdlLoader extends SOAPProxyWsdlLoader
@@ -105,10 +111,10 @@
private File wsdl_temp_file;
- public HttpSOAPProxyWsdlLoader(String url, final ConfigTree config) throws ConfigurationException
+ public HttpSOAPProxyWsdlLoader(String url, final ConfigTree config) throws IOException
{
// re-using the HTTPClient and AuthBASIC stuff...
- SOAPProxyWsdlContractPublisher wsdl_helper = new SOAPProxyWsdlContractPublisher()
+ AuthBASICWsdlContractPublisher wsdl_helper = new AuthBASICWsdlContractPublisher()
{
@Override
public Properties getActionProperties()
@@ -141,10 +147,6 @@
}
bos.flush();
}
- catch (IOException ioe)
- {
- throw new ConfigurationException(ioe);
- }
finally
{
try { if (bos != null) bos.close(); } catch (Throwable t) {}
@@ -152,7 +154,7 @@
}
}
- public URL getWsdlURL() throws MalformedURLException
+ public URL getURL() throws MalformedURLException
{
return wsdl_temp_file.toURL();
}
@@ -170,12 +172,12 @@
private File wsdl_orig_file;
- public FileSOAPProxyWsdlLoader(String path) throws ConfigurationException
+ public FileSOAPProxyWsdlLoader(String path)
{
wsdl_orig_file = new File(path);
}
- public URL getWsdlURL() throws MalformedURLException
+ public URL getURL() throws MalformedURLException
{
return wsdl_orig_file.toURL();
}
@@ -187,12 +189,12 @@
private URL wsdl_url;
- public ClasspathSOAPProxyWsdlLoader(String resource) throws ConfigurationException
+ public ClasspathSOAPProxyWsdlLoader(String resource)
{
wsdl_url = ClassUtil.getResource(resource, SOAPProxyWsdlLoader.class);
}
- public URL getWsdlURL() throws MalformedURLException
+ public URL getURL() throws MalformedURLException
{
return wsdl_url;
}
@@ -204,7 +206,7 @@
private File wsdl_temp_file;
- public InternalSOAPProxyWsdlLoader(String end_name) throws ConfigurationException
+ public InternalSOAPProxyWsdlLoader(String end_name) throws IOException
{
SPIProvider spi_prov = SPIProviderResolver.getInstance().getProvider();
EndpointRegistryFactory end_reg_fact = spi_prov.getSPI(EndpointRegistryFactory.class);
@@ -229,10 +231,6 @@
end.getRequestHandler().handleWSDLRequest(end, bos, null);
bos.flush();
}
- catch (IOException ioe)
- {
- throw new ConfigurationException(ioe);
- }
finally
{
try { if (bos != null) bos.close(); } catch (Throwable t) {}
@@ -240,11 +238,11 @@
}
else
{
- throw new ConfigurationException("unrecognized internal endpoint: " + end_name);
+ throw new IOException("unrecognized internal endpoint: " + end_name);
}
}
- public URL getWsdlURL() throws MalformedURLException
+ public URL getURL() throws MalformedURLException
{
return wsdl_temp_file.toURL();
}
More information about the jboss-svn-commits
mailing list