JBossWS SVN: r11164 - spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-11-27 13:05:01 -0500 (Fri, 27 Nov 2009)
New Revision: 11164
Added:
spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
Modified:
spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
Log:
[JBPAPP-3177] Cache resource name lookup through Services API
Added: spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
===================================================================
--- spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java (rev 0)
+++ spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java 2009-11-27 18:05:01 UTC (rev 11164)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.spi.util;
+
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ */
+ static void setContextClassLoader(final ClassLoader cl)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Get resource as stream
+ *
+ * @param cl
+ * @param filename
+ * @return input stream
+ * @throws PrivilegedActionException
+ */
+ static InputStream getResourceAsStream(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run()
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
Property changes on: spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
===================================================================
--- spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2009-11-27 18:04:04 UTC (rev 11163)
+++ spi/branches/jbossws-spi-1.1.2/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2009-11-27 18:05:01 UTC (rev 11164)
@@ -29,7 +29,11 @@
import java.io.InputStreamReader;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Map;
import java.util.Properties;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Load a service class using this ordered lookup procedure
@@ -40,6 +44,12 @@
public abstract class ServiceLoader
{
/**
+ * A synchronized weak hash map that keeps factory names retrieved using Service API (META-INF/services/*) for each classloader.
+ * Weak keys are used to remove entries when classloaders are garbage collected; values are service-property-name -> factory name maps.
+ */
+ private static Map<ClassLoader, Map<String, String>> serviceMap = Collections.synchronizedMap(new WeakHashMap<ClassLoader, Map<String, String>>());
+
+ /**
* This method uses the algorithm below using the JAXWS Provider as an example.
*
* 1. If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then
@@ -78,25 +88,19 @@
// Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
String filename = "META-INF/services/" + propertyName;
- InputStream inStream = loader.getResourceAsStream(filename);
- if (inStream != null)
+ try
{
- try
+ factoryName = getServiceNameUsingCache(loader, filename);
+ if (factoryName != null)
{
- BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
- factoryName = br.readLine();
- br.close();
- if (factoryName != null)
- {
- Class factoryClass = loader.loadClass(factoryName);
- factory = factoryClass.newInstance();
- }
+ Class<?> factoryClass = SecurityActions.loadClass(loader, factoryName);
+ factory = factoryClass.newInstance();
}
- catch (Throwable t)
- {
- throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
- }
}
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+ }
// Use the default factory implementation class.
if (factory == null && defaultFactory != null)
@@ -106,6 +110,33 @@
return factory;
}
+
+ private static String getServiceNameUsingCache(ClassLoader loader, String filename) throws IOException
+ {
+ Map<String, String> map = serviceMap.get(loader);
+ if (map != null && map.containsKey(filename))
+ {
+ return map.get(filename);
+ }
+ else
+ {
+ if (map == null)
+ {
+ map = new ConcurrentHashMap<String, String>();
+ serviceMap.put(loader, map);
+ }
+ InputStream inStream = SecurityActions.getResourceAsStream(loader, filename);
+ String factoryName = null;
+ if (inStream != null)
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
+ factoryName = br.readLine();
+ br.close();
+ map.put(filename, factoryName);
+ }
+ return factoryName;
+ }
+ }
/** Use the system property
*/
15 years
JBossWS SVN: r11163 - stack/native/branches/jbossws-native-3.1.2.SP4.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-11-27 13:04:04 -0500 (Fri, 27 Nov 2009)
New Revision: 11163
Modified:
stack/native/branches/jbossws-native-3.1.2.SP4/pom.xml
Log:
Moving to spi snapshot + adding brew repository
Modified: stack/native/branches/jbossws-native-3.1.2.SP4/pom.xml
===================================================================
--- stack/native/branches/jbossws-native-3.1.2.SP4/pom.xml 2009-11-27 07:17:15 UTC (rev 11162)
+++ stack/native/branches/jbossws-native-3.1.2.SP4/pom.xml 2009-11-27 18:04:04 UTC (rev 11163)
@@ -49,7 +49,7 @@
<properties>
<jbossws.common.version>1.1.0.SP2</jbossws.common.version>
<jbossws.framework.version>3.1.2-SNAPSHOT</jbossws.framework.version>
- <jbossws.spi.version>1.1.2.SP1</jbossws.spi.version>
+ <jbossws.spi.version>1.1.2-SNAPSHOT</jbossws.spi.version>
<!-- [JBWS-2505] -->
<!-- START -->
<!--
@@ -403,6 +403,13 @@
</snapshots>
</repository>
<repository>
+ <id>repository-prod.jboss.org</id>
+ <url>http://repository.jboss.org/maven2-brew</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
<id>snapshots.jboss.org</id>
<url>http://snapshots.jboss.org/maven2</url>
<snapshots>
15 years
JBossWS SVN: r11162 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws: tools/jaxws/impl and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-11-27 02:17:15 -0500 (Fri, 27 Nov 2009)
New Revision: 11162
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/jaxws/impl/JBossWSProviderImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java
Log:
[JBWS-2840] implementing in Native
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2009-11-27 07:16:00 UTC (rev 11161)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2009-11-27 07:17:15 UTC (rev 11162)
@@ -82,6 +82,7 @@
public class JAXWSWebServiceMetaDataBuilder extends JAXWSServerMetaDataBuilder
{
private boolean generateWsdl = true;
+ private boolean extension;
private boolean toolMode = false;
private File wsdlDirectory = null;
private PrintStream messageStream = null;
@@ -99,6 +100,11 @@
{
this.generateWsdl = generateWsdl;
}
+
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
public ServerEndpointMetaData buildWebServiceMetaData(Deployment dep, UnifiedMetaData wsMetaData, Class<?> sepClass, String linkName)
{
@@ -382,6 +388,7 @@
try
{
WSDLGenerator generator = new JAXBWSDLGenerator(jaxbCtx);
+ generator.setExtension(extension);
WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
if (wsdlLocation != null)
{
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/jaxws/impl/JBossWSProviderImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/jaxws/impl/JBossWSProviderImpl.java 2009-11-27 07:16:00 UTC (rev 11161)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/jaxws/impl/JBossWSProviderImpl.java 2009-11-27 07:17:15 UTC (rev 11162)
@@ -46,11 +46,12 @@
final class JBossWSProviderImpl extends WSContractProvider
{
private ClassLoader loader;
- private boolean generateWsdl = false;
- private boolean generateSource = false;
+ private boolean generateWsdl;
+ private boolean extension;
+ private boolean generateSource;
private File outputDir = new File("output");
- private File resourceDir = null;
- private File sourceDir = null;
+ private File resourceDir;
+ private File sourceDir;
private PrintStream messageStream = NullPrintStream.getInstance();
private void createDirectories(File resourceDir, File sourceDir)
@@ -95,7 +96,8 @@
builder.setGenerateWsdl(generateWsdl);
builder.setToolMode(true);
builder.setWsdlDirectory(resourceDir);
- builder.setMessageStream(messageStream);
+ builder.setMessageStream(messageStream);
+ builder.setExtension(extension);
if (generateWsdl)
messageStream.println("Generating WSDL:");
@@ -142,6 +144,12 @@
}
@Override
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
+
+ @Override
public void setOutputDirectory(File directory)
{
outputDir = directory;
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java 2009-11-27 07:16:00 UTC (rev 11161)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java 2009-11-27 07:17:15 UTC (rev 11162)
@@ -80,6 +80,8 @@
public abstract class WSDLGenerator
{
protected WSDLDefinitions wsdl;
+
+ protected boolean extension;
protected abstract void processTypes();
@@ -109,6 +111,8 @@
QName bindingQName = new QName(interfaceQName.getNamespaceURI(), interfaceQName.getLocalPart() + "Binding");
WSDLBinding wsdlBinding = new WSDLBinding(wsdl, bindingQName);
wsdlBinding.setInterfaceName(interfaceQName);
+ if (extension)
+ endpoint.setBindingId(SOAPBinding.SOAP12HTTP_BINDING);
wsdlBinding.setType(endpoint.getBindingId());
wsdl.addBinding(wsdlBinding);
wsdlEndpoint.setBinding(bindingQName);
@@ -466,6 +470,16 @@
wsdlService.setInterfaceName(endpoint.getPortName());
}
+
+ /**
+ * Whether to force SOAP 1.2
+ *
+ * @param extension whether to force SOAP 1.2
+ */
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
/**
* Generate a WSDL object model from the passed in ServiceMetaData.
@@ -497,26 +511,30 @@
}
}
- String soapURI = null;
- String soapPrefix = null;
- for (EndpointMetaData ep : service.getEndpoints())
+ String soapPrefix = extension ? "soap12" : null;
+ String soapURI = extension ? Constants.NS_SOAP12 : null;
+ if (!extension)
{
- String bindingId = ep.getBindingId();
- if (bindingId.startsWith(SOAPBinding.SOAP11HTTP_BINDING))
+ for (EndpointMetaData ep : service.getEndpoints())
{
- soapPrefix = "soap";
- soapURI = Constants.NS_SOAP11;
+ String bindingId = ep.getBindingId();
+ if (bindingId.startsWith(SOAPBinding.SOAP11HTTP_BINDING))
+ {
+ soapPrefix = "soap";
+ soapURI = Constants.NS_SOAP11;
+ }
+ else if (bindingId.startsWith(SOAPBinding.SOAP12HTTP_BINDING))
+ {
+ soapPrefix = "soap12";
+ soapURI = Constants.NS_SOAP12;
+ }
+
}
- else if (bindingId.startsWith(SOAPBinding.SOAP12HTTP_BINDING))
- {
- soapPrefix = "soap12";
- soapURI = Constants.NS_SOAP12;
- }
}
if (soapURI != null && soapPrefix != null)
wsdl.registerNamespaceURI(soapURI, soapPrefix);
-
+
processTypes();
processService(service);
15 years
JBossWS SVN: r11161 - stack/metro/trunk/modules/client/src/main/java/org/jboss/wsf/stack/metro/tools.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-11-27 02:16:00 -0500 (Fri, 27 Nov 2009)
New Revision: 11161
Modified:
stack/metro/trunk/modules/client/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java
Log:
[JBWS-2840] implementing in Metro
Modified: stack/metro/trunk/modules/client/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java
===================================================================
--- stack/metro/trunk/modules/client/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java 2009-11-27 07:15:28 UTC (rev 11160)
+++ stack/metro/trunk/modules/client/src/main/java/org/jboss/wsf/stack/metro/tools/MetroProviderImpl.java 2009-11-27 07:16:00 UTC (rev 11161)
@@ -39,11 +39,12 @@
{
private ClassLoader loader;
- private boolean generateWsdl = false;
- private boolean generateSource = false;
+ private boolean generateWsdl;
+ private boolean extension;
+ private boolean generateSource;
private File outputDir = new File("output");
- private File resourceDir = null;
- private File sourceDir = null;
+ private File resourceDir;
+ private File sourceDir;
private PrintStream messageStream = new NullPrintStream();
public MetroProviderImpl()
@@ -55,6 +56,11 @@
this.generateWsdl = generateWsdl;
}
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
+
public void setGenerateSource(boolean generateSource)
{
this.generateSource = generateSource;
@@ -157,8 +163,17 @@
}
// -wsdl[:protocol]
- if (generateWsdl) {
- args.add("-wsdl");
+ if (generateWsdl)
+ {
+ if (extension)
+ {
+ args.add("-wsdl:Xsoap1.2");
+ args.add("-extension");
+ }
+ else
+ {
+ args.add("-wsdl");
+ }
}
// --classpath
15 years
JBossWS SVN: r11160 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/tools.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-11-27 02:15:28 -0500 (Fri, 27 Nov 2009)
New Revision: 11160
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/tools/CXFProviderImpl.java
Log:
[JBWS-2840] implementing in CXF
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/tools/CXFProviderImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/tools/CXFProviderImpl.java 2009-11-27 07:14:19 UTC (rev 11159)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/tools/CXFProviderImpl.java 2009-11-27 07:15:28 UTC (rev 11160)
@@ -42,11 +42,12 @@
public class CXFProviderImpl extends WSContractProvider
{
private ClassLoader loader;
- private boolean generateWsdl = false;
- private boolean generateSource = false;
+ private boolean generateWsdl;
+ private boolean extension;
+ private boolean generateSource;
private File outputDir = new File("output");
- private File resourceDir = null;
- private File sourceDir = null;
+ private File resourceDir;
+ private File sourceDir;
private PrintStream messageStream;
public CXFProviderImpl()
@@ -58,6 +59,11 @@
this.generateWsdl = generateWsdl;
}
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
+
public void setGenerateSource(boolean generateSource)
{
this.generateSource = generateSource;
@@ -157,9 +163,12 @@
stream = NullPrintStream.getInstance();
}
+ // -wsdl[:protocol]
if (generateWsdl)
{
args.add("-wsdl");
+ if (extension)
+ args.add("-soap12");
}
String cp = buildClasspathString(loader);
15 years
JBossWS SVN: r11159 - framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-11-27 02:14:19 -0500 (Fri, 27 Nov 2009)
New Revision: 11159
Modified:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
Log:
[JBWS-2840] providing test case
Modified: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java 2009-11-27 07:09:50 UTC (rev 11158)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderPlugin.java 2009-11-27 07:14:19 UTC (rev 11159)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.ws.jaxws.smoke.tools;
+import org.jboss.ws.Constants;
import org.jboss.wsf.common.DOMUtils;
import org.jboss.wsf.spi.tools.WSContractProvider;
import org.jboss.wsf.test.JBossWSTest;
@@ -86,6 +87,20 @@
}
/**
+ * Enables/Disables WSDL generation.
+ *
+ */
+ public void testGenerateWsdlWithExtension() throws Exception
+ {
+ provider.setGenerateWsdl(true);
+ provider.setExtension(true);
+ File outputDir = new File(outputDirectory.getAbsolutePath() + "-soap12");
+ provide(outputDir);
+
+ verifyWSDL(outputDir, true);
+ }
+
+ /**
* Enables/Disables Java source generation.
*
*/
@@ -177,13 +192,18 @@
provider.setResourceDirectory(directory);
provide();
- verifyWSDL(directory);
+ verifyWSDL(outputDirectory);
}
-
+
private void verifyWSDL(File directory) throws Exception
{
+ this.verifyWSDL(directory, false);
+ }
+
+ private void verifyWSDL(File directory, boolean soap12) throws Exception
+ {
File wsdl = new File(
- outputDirectory.getAbsolutePath()+
+ directory.getAbsolutePath()+
FS + "CalculatorBeanService.wsdl"
);
@@ -191,6 +211,16 @@
Element root = DOMUtils.parse( new FileInputStream(wsdl));
Element serviceElement = DOMUtils.getFirstChildElement(root, "service");
assertEquals(serviceElement.getAttribute("name"), "CalculatorBeanService");
+ Element bindingElement = DOMUtils.getFirstChildElement(root, "binding");
+ Element soapBindingElement = DOMUtils.getFirstChildElement(bindingElement,"binding");
+ if (soap12)
+ {
+ assertEquals("http://schemas.xmlsoap.org/wsdl/soap12/", soapBindingElement.getNamespaceURI());
+ }
+ else
+ {
+ assertEquals("http://schemas.xmlsoap.org/wsdl/soap/", soapBindingElement.getNamespaceURI());
+ }
}
/**
@@ -283,7 +313,11 @@
private void provide() throws Exception
{
- //provider.setGenerateSource(true);
+ this.provide(outputDirectory);
+ }
+
+ private void provide(File outputDirectory)
+ {
provider.setOutputDirectory(outputDirectory);
provider.provide(CalculatorBean.class);
}
Modified: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java 2009-11-27 07:09:50 UTC (rev 11158)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/WSProviderTestCase.java 2009-11-27 07:14:19 UTC (rev 11159)
@@ -50,6 +50,11 @@
{
dispatch("testGenerateWsdl");
}
+
+ public void testGenerateWsdlWithExtension() throws Exception
+ {
+ dispatch("testGenerateWsdlWithExtension");
+ }
public void testGenerateSource() throws Exception
{
15 years
JBossWS SVN: r11158 - in spi/trunk/src: main/java/org/jboss/wsf/spi/tools/ant and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2009-11-27 02:09:50 -0500 (Fri, 27 Nov 2009)
New Revision: 11158
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
Log:
[JBWS-2840] implementation
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java 2009-11-25 19:21:33 UTC (rev 11157)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java 2009-11-27 07:09:50 UTC (rev 11158)
@@ -98,6 +98,13 @@
* @param generateWsdl whether or not to generate WSDL
*/
public abstract void setGenerateWsdl(boolean generateWsdl);
+
+ /**
+ * Enables/Disables SOAP 1.2 binding extension
+ *
+ * @param extension whether or not to enable SOAP 1.2 binding extension
+ */
+ public abstract void setExtension(boolean extension);
/**
* Enables/Disables Java source generation.
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java 2009-11-25 19:21:33 UTC (rev 11157)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java 2009-11-27 07:09:50 UTC (rev 11158)
@@ -53,8 +53,9 @@
* <tr><td>resourcedestdir</td><td>The output directory for resource artifacts (WSDL/XSD).</td><td>value of destdir</td></tr>
* <tr><td>sourcedestdir</td><td>The output directory for Java source.</td><td>value of destdir</td></tr>
* <tr><td>genwsdl</td><td>Whether or not to generate WSDL.</td><td>false</td><tr>
+ * <tr><td>extension</td><td>Enable SOAP 1.2 binding extension.</td><td>false</td></tr>
* <tr><td>verbose</td><td>Enables more informational output about cmd progress.</td><td>false</td><tr>
- * <tr><td>sei*</td><td>Service Endpoint Implementation.</td><td></td><tr>
+ * <tr><td>sei</td><td>Service Endpoint Implementation.</td><td></td><tr>
* <tr><td>classpath</td><td>The classpath that contains the service endpoint implementation.</td><td>""</tr>
* </table>
* <b>* = required.</b>
@@ -73,6 +74,7 @@
* resourcedestdir="out-resource"
* sourcedestdir="out-source"
* genwsdl="true"
+ * extension="true"
* verbose="true"
* sei="org.jboss.test.ws.jaxws.jsr181.soapbinding.DocWrappedServiceImpl">
* <classpath>
@@ -83,20 +85,22 @@
* </pre>
*
* @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
public class WSProvideTask extends Task
{
private Path classpath = new Path(getProject());
private CommandlineJava command = new CommandlineJava();
- private String sei = null;
- private File destdir = null;
- private File resourcedestdir = null;
- private File sourcedestdir = null;
- private boolean keep = false;
- private boolean genwsdl = false;
- private boolean verbose = false;
- private boolean fork = false;
- private boolean debug = false;
+ private String sei;
+ private File destdir;
+ private File resourcedestdir;
+ private File sourcedestdir;
+ private boolean keep;
+ private boolean extension;
+ private boolean genwsdl;
+ private boolean verbose;
+ private boolean fork;
+ private boolean debug;
// Not actually used right now
public void setDebug(boolean debug)
@@ -128,7 +132,20 @@
{
this.destdir = destdir;
}
+
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
+ public void setProtocol(String protocol)
+ {
+ if (protocol != null)
+ {
+ this.extension = protocol.toLowerCase().indexOf("Xsoap1.2") != -1;
+ }
+ }
+
public void setKeep(boolean keep)
{
this.keep = keep;
@@ -208,6 +225,8 @@
gen.setMessageStream(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)));
gen.setGenerateSource(keep);
gen.setGenerateWsdl(genwsdl);
+ gen.setExtension(extension);
+
if (destdir != null)
gen.setOutputDirectory(destdir);
if (resourcedestdir != null)
@@ -266,6 +285,9 @@
if (genwsdl)
command.createArgument().setValue("-w");
+ if (extension)
+ command.createArgument().setValue("-e");
+
if (destdir != null)
{
command.createArgument().setValue("-o");
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java 2009-11-25 19:21:33 UTC (rev 11157)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java 2009-11-27 07:09:50 UTC (rev 11158)
@@ -59,18 +59,18 @@
public class WSConsume
{
private List<File> bindingFiles = new ArrayList<File>();
- private boolean generateSource = false;
- private File catalog = null;
- private String targetPackage = null;
- private String wsdlLocation = null;
- private boolean quiet = false;
- private boolean verbose = false;
- private boolean loadConsumer = false;
- private boolean extension = false;
- private boolean noCompile = false;
private File outputDir = new File("output");
- private File sourceDir = null;
- private String target = null;
+ private boolean generateSource;
+ private File catalog;
+ private String targetPackage;
+ private String wsdlLocation;
+ private boolean quiet;
+ private boolean verbose;
+ private boolean loadConsumer;
+ private boolean extension;
+ private boolean noCompile;
+ private File sourceDir;
+ private String target;
public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSConsume.class.getName());
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java 2009-11-25 19:21:33 UTC (rev 11157)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java 2009-11-27 07:09:50 UTC (rev 11158)
@@ -51,21 +51,23 @@
* -q, --quiet Be somewhat more quiet
* -t, --show-traces Show full exception stack traces
* -l, --load-provider Load the provider and exit (debug utility)
+ * -e, --extension Enable SOAP 1.2 binding extension
* </pre>
*
* @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
*/
public class WSProvide
{
- private boolean generateSource = false;
- private boolean generateWsdl = false;
- private boolean quiet = false;
- private boolean showTraces = false;
- private boolean loadProvider = false;
private ClassLoader loader = SecurityActions.getContextClassLoader();
private File outputDir = new File("output");
- private File resourceDir = null;
- private File sourceDir = null;
+ private boolean generateSource;
+ private boolean generateWsdl;
+ private boolean extension;
+ private boolean quiet;
+ private boolean showTraces;
+ private boolean loadProvider;
+ private File resourceDir;
+ private File sourceDir;
public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSProvide.class.getSimpleName());
@@ -78,7 +80,7 @@
private String parseArguments(String[] args)
{
- String shortOpts = "hwko:r:s:c:qtl";
+ String shortOpts = "hwko:r:s:c:qtle";
LongOpt[] longOpts =
{
new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
@@ -91,6 +93,7 @@
new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
new LongOpt("show-traces", LongOpt.NO_ARGUMENT, null, 't'),
new LongOpt("load-provider", LongOpt.NO_ARGUMENT, null, 'l'),
+ new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
};
Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
@@ -126,6 +129,9 @@
case 'l':
loadProvider = true;
break;
+ case 'e':
+ extension = true;
+ break;
case 'h':
printHelp();
System.exit(0);
@@ -170,6 +176,7 @@
gen.setGenerateWsdl(generateWsdl);
gen.setGenerateSource(generateSource);
gen.setOutputDirectory(outputDir);
+ gen.setExtension(extension);
if (resourceDir != null)
gen.setResourceDirectory(resourceDir);
if (sourceDir != null)
@@ -234,9 +241,10 @@
out.println(" -o, --output=<directory> The directory to put generated artifacts");
out.println(" -r, --resource=<directory> The directory to put resource artifacts");
out.println(" -s, --source=<directory> The directory to put Java source");
+ out.println(" -e, --extension Enable SOAP 1.2 binding extension");
out.println(" -q, --quiet Be somewhat more quiet");
out.println(" -t, --show-traces Show full exception stack traces");
- out.println(" -l, --load-provider Load the provider and exit (debug utility)");
- out.flush();
+ out.println(" -l, --load-provider Load the provider and exit (debug utility)");
+ out.flush();
}
}
Modified: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java 2009-11-25 19:21:33 UTC (rev 11157)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java 2009-11-27 07:09:50 UTC (rev 11158)
@@ -39,6 +39,11 @@
LAST_EVENT += "setGenerateWsdl";
}
+ public void setExtension(boolean extension)
+ {
+ LAST_EVENT += "setExtension";
+ }
+
public void setGenerateSource(boolean generateSource)
{
LAST_EVENT += "setGenerateSource";
15 years
JBossWS SVN: r11157 - in stack/native/trunk/modules: core/src/main/java/org/jboss/wsf/stack/jbws and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2009-11-25 14:21:33 -0500 (Wed, 25 Nov 2009)
New Revision: 11157
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/config/WSDLRequestHandlerTestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/schema1.xsd
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/test.wsdl
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/testUndefinedHost.wsdl
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
Log:
[JBWS-2842] Adding testcase, fixing issue, refactoring WSDLRequestHandler to make it testable
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-11-25 15:47:27 UTC (rev 11156)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2009-11-25 19:21:33 UTC (rev 11157)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -23,12 +23,12 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.jboss.logging.Logger;
-import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.wsf.common.DOMUtils;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
@@ -49,6 +49,8 @@
* For a discussion of this topic.
*
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
+ *
* @since 23-Mar-2005
*/
public class WSDLRequestHandler
@@ -56,38 +58,77 @@
// provide logging
private static Logger log = Logger.getLogger(WSDLRequestHandler.class);
- private final EndpointMetaData epMetaData;
+ private final URL wsdlLocation;
+ private final String wsdlPublishLoc;
private final ServerConfig config;
- public WSDLRequestHandler(EndpointMetaData epMetaData)
+ public WSDLRequestHandler(URL wsdlLocationFromMetadata, String wsdlPublishLocationFromMetadata, ServerConfig config)
{
- this.epMetaData = epMetaData;
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- this.config = spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
+ this.wsdlLocation = wsdlLocationFromMetadata;
+ this.wsdlPublishLoc = wsdlPublishLocationFromMetadata;
+ this.config = config;
}
+
+ public Document getDocumentForPath(URL reqURL, String resPath) throws IOException
+ {
+ String wsdlHost = reqURL.getHost();
+ boolean rewriteUsingCalledURL = ServerConfig.UNDEFINED_HOSTNAME.equals(config.getWebServiceHost());
+ if (!rewriteUsingCalledURL)
+ {
+ wsdlHost = config.getWebServiceHost();
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("WSDL request, using host: " + wsdlHost);
+
+ return getDocumentForPath(reqURL, wsdlHost, rewriteUsingCalledURL, resPath);
+ }
+
+ protected InputStream openStreamToWSDL() throws IOException
+ {
+ return wsdlLocation.openStream();
+ }
+
/**
* Get the WSDL resource for a given resource path
* <p/>
* Use path value of null to get the root document
*
+ * @param reqURL The full request url
+ * @param wsdlHost The host to be used for address rewrite in the wsdl
+ * @param rewriteUsingCalledURL True if the called url is being used to get the wsdlHost (and the port to use for relative addresses in import/include elements)
* @param resPath The wsdl resource to get, can be null for the top level wsdl
* @return A wsdl document, or null if it cannot be found
*/
- public Document getDocumentForPath(URL reqURL, String wsdlHost, String resPath) throws IOException
+ private Document getDocumentForPath(URL reqURL, String wsdlHost, boolean rewriteUsingCalledURL, String resPath) throws IOException
{
Document wsdlDoc;
- // The WSDLFilePublisher should set the location to an URL
- URL wsdlLocation = epMetaData.getServiceMetaData().getWsdlLocation();
if (wsdlLocation == null)
throw new IllegalStateException("Cannot obtain wsdl location");
// get the root wsdl
if (resPath == null)
{
- Element wsdlElement = DOMUtils.parse(wsdlLocation.openStream());
- wsdlDoc = wsdlElement.getOwnerDocument();
+ InputStream is = null;
+ try
+ {
+ is = openStreamToWSDL();
+ Element wsdlElement = DOMUtils.parse(is);
+ wsdlDoc = wsdlElement.getOwnerDocument();
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception e)
+ {
+ //ignore
+ }
+ }
}
// get some imported resource
@@ -96,7 +137,6 @@
File wsdlLocFile = new File(wsdlLocation.getPath());
String impResourcePath = wsdlLocFile.getParent() + File.separatorChar + resPath;
File impResourceFile = new File(impResourcePath);
- String wsdlPublishLoc = epMetaData.getServiceMetaData().getWsdlPublishLocation();
if (log.isDebugEnabled())
log.debug("Importing resource file: " + impResourceFile.getCanonicalPath());
@@ -122,14 +162,14 @@
}
}
- modifyAddressReferences(reqURL, wsdlHost, resPath, wsdlDoc.getDocumentElement());
+ modifyAddressReferences(reqURL, wsdlHost, rewriteUsingCalledURL, resPath, wsdlDoc.getDocumentElement());
return wsdlDoc;
}
/**
* Modify the location of wsdl and schema imports
*/
- private void modifyAddressReferences(URL reqURL, String wsdlHost, String resPath, Element element) throws IOException
+ private void modifyAddressReferences(URL reqURL, String wsdlHost, boolean rewriteUsingCalledURL, String resPath, Element element) throws IOException
{
// map wsdl definition imports
NodeList nlist = element.getChildNodes();
@@ -189,13 +229,10 @@
String reqPath = reqURL.getPath();
String completeHost = wsdlHost;
- if (!(wsdlHost.startsWith("http://") || wsdlHost.startsWith("https://")))
- {
- String reqProtocol = reqURL.getProtocol();
- int reqPort = reqURL.getPort();
- String hostAndPort = wsdlHost + (reqPort > 0 ? ":" + reqPort : "");
- completeHost = reqProtocol + "://" + hostAndPort;
- }
+ String reqProtocol = reqURL.getProtocol();
+ int reqPort = rewriteUsingCalledURL ? reqURL.getPort() : getPortForProtocol(reqProtocol);
+ String hostAndPort = wsdlHost + (reqPort > 0 ? ":" + reqPort : "");
+ completeHost = reqProtocol + "://" + hostAndPort;
String newLocation = completeHost + reqPath + "?wsdl&resource=" + newResourcePath;
locationAttr.setNodeValue(newLocation);
@@ -229,7 +266,15 @@
boolean confidential = "https".equalsIgnoreCase(orgProtocol);
String reqProtocol = reqURL.getProtocol();
- int port = confidential ? getPortForProtocol("https") : getPortForProtocol(reqProtocol);
+ int port;
+ if (rewriteUsingCalledURL)
+ {
+ port = reqURL.getPort();
+ }
+ else
+ {
+ port = confidential ? getPortForProtocol("https") : getPortForProtocol(reqProtocol);
+ }
String path = orgURL.getPath();
String newLocation = new URL(confidential ? "https" : reqProtocol, wsdlHost, port, path).toString();
if (!newLocation.equals(orgLocation))
@@ -244,12 +289,13 @@
}
else
{
- modifyAddressReferences(reqURL, wsdlHost, resPath, childElement);
+ modifyAddressReferences(reqURL, wsdlHost, rewriteUsingCalledURL, resPath, childElement);
}
}
}
}
+
private static boolean isHttp(String orgLocation)
{
try
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-11-25 15:47:27 UTC (rev 11156)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-11-25 19:21:33 UTC (rev 11157)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -51,8 +51,6 @@
import javax.xml.ws.http.HTTPBinding;
import org.jboss.logging.Logger;
-import org.jboss.netty.handler.codec.http.HttpMessage;
-import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonBinding;
@@ -234,6 +232,7 @@
}
}
+ @SuppressWarnings("unchecked")
public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream outStream, InvocationContext invContext)
{
if (log.isDebugEnabled())
@@ -691,18 +690,14 @@
ServerEndpointMetaData epMetaData = endpoint.getAttachment(ServerEndpointMetaData.class);
if (epMetaData == null)
throw new IllegalStateException("Cannot obtain endpoint meta data");
+
+ //The WSDLFilePublisher should set the location to an URL
+ URL wsdlLocation = epMetaData.getServiceMetaData().getWsdlLocation();
+ String wsdlPublishLoc = epMetaData.getServiceMetaData().getWsdlPublishLocation();
- String wsdlHost = reqURL.getHost();
+ WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(wsdlLocation, wsdlPublishLoc, serverConfig);
+ Document document = wsdlRequestHandler.getDocumentForPath(reqURL, resPath);
- if (ServerConfig.UNDEFINED_HOSTNAME.equals(serverConfig.getWebServiceHost()) == false)
- wsdlHost = serverConfig.getWebServiceHost();
-
- if (log.isDebugEnabled())
- log.debug("WSDL request, using host: " + wsdlHost);
-
- WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
- Document document = wsdlRequestHandler.getDocumentForPath(reqURL, wsdlHost, resPath);
-
OutputStreamWriter writer = new OutputStreamWriter(outputStream);
new DOMWriter(writer, Constants.DEFAULT_XML_CHARSET).setPrettyprint(true).print(document);
}
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/config/WSDLRequestHandlerTestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/config/WSDLRequestHandlerTestCase.java (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/config/WSDLRequestHandlerTestCase.java 2009-11-25 19:21:33 UTC (rev 11157)
@@ -0,0 +1,256 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.common.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.UnknownHostException;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.ws.core.server.WSDLRequestHandler;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.test.JBossWSTest;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Comprehensive testcase for WSDLRequestHandler's address rewrite rules
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 25-Nov-2009
+ */
+public class WSDLRequestHandlerTestCase extends JBossWSTest
+{
+ private static final String wsdlPublishLocation = "/foo/bar";
+
+ public void testNoAlwaysModifyWithValidSoapAddress() throws Exception
+ {
+ File wsdl = getResourceFile("common/config/test.wsdl");
+ ServerConfig config = new TestConfig(false, "myHost", 8080, 8443);
+
+ URL wsdlLocation = new URL("http://www.foo.org/c/d");
+ WSDLRequestHandler handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ Document doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://blah/blah", getSoapAddressLocation(doc)); //no rewrite because the modifySoapAddress is false (and the soap:address in the wsdl is "valid")
+ assertEquals("http://myHost:8080/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports locations are always rewritten
+
+ //test with rewrite based on called uri (for multiple virtual host support, see JBWS-1178 and subsequent jira issues)
+ config = new TestConfig(false, ServerConfig.UNDEFINED_HOSTNAME, 8080, 8443);
+ handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://blah/blah", getSoapAddressLocation(doc)); //no rewrite because the modifySoapAddress is false (and the soap:address in the wsdl is "valid")
+ assertEquals("http://localhost:80/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports rewritten with caller data because UNDEFINED_HOSTNAME
+ //was specified (required for multiple virtual host support)
+ }
+
+ public void testAlwaysModifyValidSoapAddress() throws Exception
+ {
+ File wsdl = getResourceFile("common/config/test.wsdl");
+ ServerConfig config = new TestConfig(true, "myHost", 8080, 8443);
+
+ URL wsdlLocation = new URL("http://www.foo.org");
+ WSDLRequestHandler handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ Document doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://myHost:8080/blah", getSoapAddressLocation(doc)); //rewrite with provided host and port (always modify is true)
+ assertEquals("http://myHost:8080/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports locations are always rewritten
+
+ //test with rewrite based on called uri (for multiple virtual host support, see JBWS-1178 and subsequent jira issues)
+ config = new TestConfig(true, ServerConfig.UNDEFINED_HOSTNAME, 8080, 8443);
+
+ handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://localhost:80/blah", getSoapAddressLocation(doc)); //rewrite with called host and port (always modify is true)
+ assertEquals("http://localhost:80/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports rewritten with all caller data because UNDEFINED_HOSTNAME
+ //was specified (required for multiple virtual host support)
+ }
+
+ public void testNoAlwaysModifyWithUndefinedSoapAddress() throws Exception
+ {
+ File wsdl = getResourceFile("common/config/testUndefinedHost.wsdl");
+ ServerConfig config = new TestConfig(false, "myHost", 8080, 8443);
+
+ URL wsdlLocation = new URL("http://www.foo.org/c/d");
+ WSDLRequestHandler handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ Document doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://myHost:8080/zzzz", getSoapAddressLocation(doc)); //rewrite because the soap:address in the wsdl has "jbossws.undefined.host" host
+ assertEquals("http://myHost:8080/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports locations are always rewritten
+
+ //test with rewrite based on called uri (for multiple virtual host support, see JBWS-1178 and subsequent jira issues)
+ config = new TestConfig(false, ServerConfig.UNDEFINED_HOSTNAME, 8080, 8443);
+
+ handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://localhost:80/zzzz", getSoapAddressLocation(doc)); //rewrite because the soap:address in the wsdl has "jbossws.undefined.host" host
+ assertEquals("http://localhost:80/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports rewritten with caller data because UNDEFINED_HOSTNAME
+ //was specified (required for multiple virtual host support)
+ }
+
+ public void testAlwaysModifyUndefinedSoapAddress() throws Exception
+ {
+ File wsdl = getResourceFile("common/config/testUndefinedHost.wsdl");
+ ServerConfig config = new TestConfig(true, "myHost", 8080, 8443);
+
+ URL wsdlLocation = new URL("http://www.foo.org");
+ WSDLRequestHandler handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ Document doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://myHost:8080/zzzz", getSoapAddressLocation(doc)); //rewrite with provided host and port (always modify is true)
+ assertEquals("http://myHost:8080/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports locations are always rewritten
+
+ //test with rewrite based on called uri (for multiple virtual host support, see JBWS-1178 and subsequent jira issues)
+ config = new TestConfig(true, ServerConfig.UNDEFINED_HOSTNAME, 8080, 8443);
+
+ handler = new TestWSDLRequestHandler(wsdlLocation, wsdl, config);
+ doc = handler.getDocumentForPath(new URL("http://localhost:80/a/b"), null); //null resPath for getting the wsdl document
+ assertEquals("http://localhost:80/zzzz", getSoapAddressLocation(doc)); //rewrite with called host and port (always modify is true)
+ assertEquals("http://localhost:80/a/b?wsdl&resource=schema1.xsd", getXsdImportSchemaLocation(doc)); //relative imports rewritten with caller data because UNDEFINED_HOSTNAME
+ //was specified (required for multiple virtual host support)
+ }
+
+ // --------- Helper methods --------
+
+ private static String getSoapAddressLocation(Document doc)
+ {
+ Element docElement = doc.getDocumentElement();
+ Element el = (Element)DOMUtils.getChildElements(docElement, new QName("http://schemas.xmlsoap.org/wsdl/soap/","address"), true).next();
+ return el.getAttribute("location");
+ }
+
+ private static String getXsdImportSchemaLocation(Document doc)
+ {
+ Element docElement = doc.getDocumentElement();
+ Element el = (Element)DOMUtils.getChildElements(docElement, new QName("http://www.w3.org/2001/XMLSchema","import"), true).next();
+ return el.getAttribute("schemaLocation");
+ }
+
+ // --------- Test helper classes --------
+
+ private class TestWSDLRequestHandler extends WSDLRequestHandler
+ {
+ private File testWsdl;
+
+ public TestWSDLRequestHandler(URL wsdlLocationFromMetadata, File testWsdl, ServerConfig config)
+ {
+ super(wsdlLocationFromMetadata, wsdlPublishLocation, config);
+ this.testWsdl = testWsdl;
+ }
+
+ @Override
+ protected InputStream openStreamToWSDL() throws IOException
+ {
+ return testWsdl.toURL().openStream();
+ }
+
+ }
+
+ private class TestConfig implements ServerConfig
+ {
+ private boolean modifySoapAddress;
+ private String webServiceHost;
+ private int webServicePort;
+ private int webServiceSecurePort;
+
+ public TestConfig(boolean modifySoapAddress, String webServiceHost, int webServicePort, int webServiceSecurePort)
+ {
+ super();
+ this.modifySoapAddress = modifySoapAddress;
+ this.webServiceHost = webServiceHost;
+ this.webServicePort = webServicePort;
+ this.webServiceSecurePort = webServiceSecurePort;
+ }
+
+ public String getWebServiceHost()
+ {
+ return webServiceHost;
+ }
+
+ public int getWebServicePort()
+ {
+ return webServicePort;
+ }
+
+ public int getWebServiceSecurePort()
+ {
+ return webServiceSecurePort;
+ }
+
+ public boolean isModifySOAPAddress()
+ {
+ return modifySoapAddress;
+ }
+
+ public void setModifySOAPAddress(boolean flag)
+ {
+ this.modifySoapAddress = flag;
+ }
+
+ public void setWebServiceHost(String host) throws UnknownHostException
+ {
+ this.webServiceHost = host;
+ }
+
+ public void setWebServicePort(int port)
+ {
+ this.webServicePort = port;
+ }
+
+ public void setWebServiceSecurePort(int port)
+ {
+ this.webServiceSecurePort = port;
+ }
+
+ public File getHomeDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getImplementationTitle()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getImplementationVersion()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public File getServerDataDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public File getServerTempDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+
+}
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/config/WSDLRequestHandlerTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/schema1.xsd
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/schema1.xsd (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/schema1.xsd 2009-11-25 19:21:33 UTC (rev 11157)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://foo/bar" xmlns:tns="http://foo/bar" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="foo">
+ <xs:sequence>
+ <xs:element name="bar" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/schema1.xsd
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/test.wsdl
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/test.wsdl (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/test.wsdl 2009-11-25 19:21:33 UTC (rev 11157)
@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<wsdl:definitions name="EndpointService" targetNamespace="http://org.jboss.ws/jbws1178" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://org.jboss.ws/jbws1178" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema>
+ <xsd:import namespace="http://foo/bar" schemaLocation="schema1.xsd"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="return" type="xsd:string">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="echo">
+ <wsdl:part name="arg0" type="xsd:string">
+ </wsdl:part>
+ </wsdl:message>
+
+ <wsdl:portType name="Endpoint">
+ <wsdl:operation name="echo">
+ <wsdl:input message="tns:echo" name="echo">
+ </wsdl:input>
+ <wsdl:output message="tns:echoResponse" name="echoResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="EndpointServiceSoapBinding" type="tns:Endpoint">
+
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="echo">
+ <soap:operation soapAction="" style="rpc" />
+ <wsdl:input name="echo">
+ <soap:body namespace="http://org.jboss.ws/jbws1178" use="literal" />
+ </wsdl:input>
+ <wsdl:output name="echoResponse">
+ <soap:body namespace="http://org.jboss.ws/jbws1178" use="literal" />
+ </wsdl:output>
+
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="EndpointService">
+ <wsdl:port binding="tns:EndpointServiceSoapBinding" name="EndpointPort">
+ <soap:address location="http://blah/blah" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/test.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/testUndefinedHost.wsdl
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/testUndefinedHost.wsdl (rev 0)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/testUndefinedHost.wsdl 2009-11-25 19:21:33 UTC (rev 11157)
@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<wsdl:definitions name="EndpointService" targetNamespace="http://org.jboss.ws/jbws1178" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://org.jboss.ws/jbws1178" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema>
+ <xsd:import namespace="http://foo/bar" schemaLocation="schema1.xsd"/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="echoResponse">
+ <wsdl:part name="return" type="xsd:string">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="echo">
+ <wsdl:part name="arg0" type="xsd:string">
+ </wsdl:part>
+ </wsdl:message>
+
+ <wsdl:portType name="Endpoint">
+ <wsdl:operation name="echo">
+ <wsdl:input message="tns:echo" name="echo">
+ </wsdl:input>
+ <wsdl:output message="tns:echoResponse" name="echoResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="EndpointServiceSoapBinding" type="tns:Endpoint">
+
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="echo">
+ <soap:operation soapAction="" style="rpc" />
+ <wsdl:input name="echo">
+ <soap:body namespace="http://org.jboss.ws/jbws1178" use="literal" />
+ </wsdl:input>
+ <wsdl:output name="echoResponse">
+ <soap:body namespace="http://org.jboss.ws/jbws1178" use="literal" />
+ </wsdl:output>
+
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="EndpointService">
+ <wsdl:port binding="tns:EndpointServiceSoapBinding" name="EndpointPort">
+ <soap:address location="http://jbossws.undefined.host/zzzz" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Property changes on: stack/native/trunk/modules/testsuite/native-tests/src/test/resources/common/config/testUndefinedHost.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years
JBossWS SVN: r11156 - stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core.
by jbossws-commits@lists.jboss.org
Author: darran.lofthouse(a)jboss.com
Date: 2009-11-25 10:47:27 -0500 (Wed, 25 Nov 2009)
New Revision: 11156
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java
Log:
[JBPAPP-3163] ClassCastException TextImpl cannot be cast to SOAPElementImpl in CommonSOAPBinding.getParameterFromMessage.
Modified: stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java 2009-11-25 15:34:50 UTC (rev 11155)
+++ stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/CommonSOAPBinding.java 2009-11-25 15:47:27 UTC (rev 11156)
@@ -868,10 +868,19 @@
childElements = soapElement.getChildElements();
OperationMetaData opMetaData = paramMetaData.getOperationMetaData();
TypesMetaData typesMetaData = opMetaData.getEndpointMetaData().getServiceMetaData().getTypesMetaData();
- if (childElements.hasNext() && opMetaData.getStyle() == Style.DOCUMENT)
+
+ SOAPElementImpl childElement = null;
+ while (childElement == null && childElements.hasNext())
{
- SOAPElementImpl childElement = (SOAPElementImpl)childElements.next();
+ Object current = childElements.next();
+ if (current instanceof SOAPElementImpl)
+ {
+ childElement = (SOAPElementImpl)current;
+ }
+ }
+ if (childElement != null && opMetaData.getStyle() == Style.DOCUMENT)
+ {
// The parameters are expected to be lazy
SOAPContentElement aux = (SOAPContentElement)childElement;
Name elName = aux.getElementName();
15 years, 1 month