[jbossws-commits] JBossWS SVN: r2856 - in trunk: jbossws-core/src/java/org/jboss/ws/metadata/builder and 4 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Sat Apr 14 18:37:18 EDT 2007
Author: thomas.diesler at jboss.com
Date: 2007-04-14 18:37:18 -0400 (Sat, 14 Apr 2007)
New Revision: 2856
Modified:
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
trunk/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1427/JBWS1427TestCase.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/jbws944/EJB3Bean01.java
Log:
Add support for invalid wsdl when creating a service
Modified: trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -23,6 +23,8 @@
// $Id$
+import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Proxy;
import java.net.URL;
import java.util.ArrayList;
@@ -39,6 +41,7 @@
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service.Mode;
@@ -70,6 +73,7 @@
import org.jboss.ws.metadata.umdm.UnifiedMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData.Type;
import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
+import org.jboss.ws.metadata.wsdl.WSDLUtils;
/**
* Service delegates are used internally by Service objects to allow pluggability of JAX-WS implementations.
@@ -101,11 +105,34 @@
public ServiceDelegateImpl(URL wsdlURL, QName serviceName, Class serviceClass)
{
+ UnifiedVirtualFile vfsRoot;
+
// If this Service was constructed through the ServiceObjectFactory
// this thread local association should be available
usRef = ServiceObjectFactory.getServiceRefAssociation();
+ if (usRef != null)
+ {
+ vfsRoot = usRef.getVfsRoot();
- UnifiedVirtualFile vfsRoot = (usRef != null ? usRef.getVfsRoot() : new ResourceLoaderAdapter());
+ // Verify wsdl access if this is not a generic Service
+ if (wsdlURL != null && serviceClass != Service.class)
+ {
+ try
+ {
+ InputStream is = wsdlURL.openStream();
+ is.close();
+ }
+ catch (IOException e)
+ {
+ log.warn("Cannot access wsdlURL: " + wsdlURL);
+ wsdlURL = null;
+ }
+ }
+ }
+ else
+ {
+ vfsRoot = new ResourceLoaderAdapter();
+ }
if (wsdlURL != null)
{
@@ -157,14 +184,37 @@
EndpointMetaData epMetaData = serviceMetaData.getEndpoint(portName);
if (epMetaData == null)
- throw new WebServiceException("Cannot get port meta data for: " + portName);
+ {
+ log.warn("Cannot get port meta data for: " + portName);
+ if (!seiClass.isAnnotationPresent(WebService.class))
+ throw new IllegalArgumentException("Cannot find @WebService on: " + seiClass.getName());
+
+ QName portType = getPortTypeName(seiClass);
+ epMetaData = new ClientEndpointMetaData(serviceMetaData, portName, portType, Type.JAXWS);
+ }
+
String seiClassName = seiClass.getName();
epMetaData.setServiceEndpointInterfaceName(seiClassName);
return getPortInternal(epMetaData, seiClass);
}
+ private <T> QName getPortTypeName(Class<T> seiClass)
+ {
+ WebService anWebService = seiClass.getAnnotation(WebService.class);
+ String localPart = anWebService.name();
+ if (localPart.length() == 0)
+ localPart = WSDLUtils.getJustClassName(seiClass);
+
+ String nsURI = anWebService.targetNamespace();
+ if (nsURI.length() == 0)
+ nsURI = WSDLUtils.getTypeNamespace(seiClass);
+
+ QName portType = new QName(nsURI, localPart);
+ return portType;
+ }
+
@Override
/**
* The getPort method returns a stub. A service client uses this stub to invoke operations on the target service endpoint.
Modified: trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/MetaDataBuilder.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -159,7 +159,10 @@
String wsContextRoot = applMetaData.getWebServiceContextRoot();
if (wsContextRoot != null)
contextRoot = wsContextRoot;
-
+
+ String ejbClass = beanMetaData.getEjbClass();
+ String ejbClassName = WSDLUtils.getJustClassName(ejbClass);
+
UnifiedEjbPortComponentMetaData ejbpcMetaData = beanMetaData.getPortComponent();
if (ejbpcMetaData != null && ejbpcMetaData.getPortComponentURI() != null)
{
@@ -177,12 +180,11 @@
}
}
}
-
+
+ if (contextRoot == null)
+ contextRoot = ejbClassName + "Service";
if (urlPattern == null)
- {
- String ejbClass = beanMetaData.getEjbClass();
- urlPattern = ejbClass.substring(ejbClass.lastIndexOf(".") + 1);
- }
+ urlPattern = ejbClassName;
}
// If not, derive the context root from the deployment
Modified: trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -71,7 +71,7 @@
if (wsdlURL == null)
throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);
- if(log.isDebugEnabled()) log.debug("START buildMetaData: [service=" + serviceName + "]");
+ log.debug("START buildMetaData: [service=" + serviceName + "]");
try
{
UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot);
@@ -89,7 +89,7 @@
JBossXSModel schemaModel = WSDLUtils.getSchemaModel(wsdlDefinitions.getWsdlTypes());
serviceMetaData.getTypesMetaData().setSchemaModel(schemaModel);
- if(log.isDebugEnabled()) log.debug("END buildMetaData: " + wsMetaData);
+ log.debug("END buildMetaData: " + wsMetaData);
return serviceMetaData;
}
catch (RuntimeException rte)
Modified: trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-core/src/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -259,36 +259,36 @@
private EndpointResult processWebService(UnifiedMetaData wsMetaData, Class<?> sepClass, UnifiedDeploymentInfo udi) throws ClassNotFoundException, IOException
{
- WebService wsAnnotation = sepClass.getAnnotation(WebService.class);
- if (wsAnnotation == null)
+ WebService anWebService = sepClass.getAnnotation(WebService.class);
+ if (anWebService == null)
throw new WSException("Cannot obtain @WebService annotation from: " + sepClass.getName());
Class<?> seiClass = null;
String seiName;
WSDLUtils wsdlUtils = WSDLUtils.getInstance();
- String name = wsAnnotation.name();
+ String name = anWebService.name();
if (name.length() == 0)
name = WSDLUtils.getJustClassName(sepClass);
- String serviceName = wsAnnotation.serviceName();
+ String serviceName = anWebService.serviceName();
if (serviceName.length() == 0)
serviceName = name + "Service";
- String serviceNS = wsAnnotation.targetNamespace();
+ String serviceNS = anWebService.targetNamespace();
if (serviceNS.length() == 0)
serviceNS = wsdlUtils.getTypeNamespace(sepClass);
- String portName = wsAnnotation.portName();
+ String portName = anWebService.portName();
if (portName.length() == 0)
portName = name + "Port";
- String wsdlLocation = wsAnnotation.wsdlLocation();
+ String wsdlLocation = anWebService.wsdlLocation();
String interfaceNS = serviceNS; // the default, but a SEI annotation may override this
- if (wsAnnotation.endpointInterface().length() > 0)
+ if (anWebService.endpointInterface().length() > 0)
{
- seiName = wsAnnotation.endpointInterface();
+ seiName = anWebService.endpointInterface();
seiClass = udi.classLoader.loadClass(seiName);
WebService seiAnnotation = seiClass.getAnnotation(WebService.class);
Modified: trunk/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java
===================================================================
--- trunk/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLUtils.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -701,11 +701,10 @@
public String getPackageName(String typeNS)
{
String pkgname = Util.xmlNamespaceToJavaPackage(typeNS);
- int len = pkgname.length();
return pkgname;
}
- public String getTypeNamespace(Class javaType)
+ public static String getTypeNamespace(Class javaType)
{
return getTypeNamespace(JavaUtils.getPackageName(javaType));
}
@@ -713,10 +712,8 @@
/**
* Extracts the typeNS given the package name
* Algorithm is based on the one specified in JAWS v2.0 spec
- * @param packageName
- * @return the type namespace
*/
- public String getTypeNamespace(String packageName)
+ public static String getTypeNamespace(String packageName)
{
StringBuilder sb = new StringBuilder("http://");
Modified: trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1427/JBWS1427TestCase.java
===================================================================
--- trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1427/JBWS1427TestCase.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws1427/JBWS1427TestCase.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -66,7 +66,7 @@
QName serviceName = new QName("http://za.co.testws.interfaces", "ProcessClaim");
Service service = factory.createService(wsdlURL, serviceName , mappingURL);
port = (RequestService)service.getPort(RequestService.class);
- ((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://" + getServerHost() + ":8080/jaxrpc-jbws1427/SubmitRequestEJB");
+ ((Stub)port)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://" + getServerHost() + ":8080/RequestServiceEJBService/RequestServiceEJB");
}
}
Modified: trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/jbws944/EJB3Bean01.java
===================================================================
--- trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/jbws944/EJB3Bean01.java 2007-04-14 20:31:08 UTC (rev 2855)
+++ trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/jbws944/EJB3Bean01.java 2007-04-14 22:37:18 UTC (rev 2856)
@@ -1,24 +1,24 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.
- */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jaxws.jbws944;
import javax.ejb.Remote;
@@ -29,15 +29,15 @@
import javax.jws.soap.SOAPBinding;
import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.ws.annotation.WebContext;
@WebService(name = "EJB3Bean", targetNamespace = "http://org.jboss.ws/jbws944")
+ at WebContext(contextRoot = "/jaxws-jbws944", urlPattern = "/FooBean01")
@SOAPBinding(style = SOAPBinding.Style.RPC)
-
@Remote(EJB3RemoteInterface.class)
@RemoteHome(EJB3RemoteHome.class)
@RemoteBinding(jndiBinding = "/ejb3/EJB3EndpointInterface")
@Stateless(name = "FooBean01")
-
public class EJB3Bean01 implements EJB3RemoteInterface
{
@WebMethod
More information about the jbossws-commits
mailing list