Author: thomas.diesler(a)jboss.com
Date: 2007-04-16 08:28:34 -0400 (Mon, 16 Apr 2007)
New Revision: 2878
Modified:
trunk/build/eclipse/jbossws.userlibraries
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/TestEndpointService.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefClientTestCase.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java
Log:
Add support for @WebServiceRef with no DD
Modified: trunk/build/eclipse/jbossws.userlibraries
===================================================================
--- trunk/build/eclipse/jbossws.userlibraries 2007-04-16 10:31:31 UTC (rev 2877)
+++ trunk/build/eclipse/jbossws.userlibraries 2007-04-16 12:28:34 UTC (rev 2878)
@@ -10,13 +10,13 @@
<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_0/build/output/jboss-4.0.5.SP1-ejb3/server/default/deploy/ejb3.deployer/jboss-ejb3x.jar"/>
</library>
<library name="jboss-4.2.x" systemlibrary="false">
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/lib/jboss-jmx.jar"/>
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/lib/jboss-system.jar"/>
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/server/default/lib/jboss.jar"/>
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/server/default/lib/jboss-ejb3x.jar"/>
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/server/default/deploy/ejb3.deployer/jboss-annotations-ejb3.jar"/>
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/server/default/deploy/ejb3.deployer/jboss-ejb3.jar"/>
-<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.CR2/server/default/deploy/jboss-aop-jdk50.deployer/jboss-aop-jdk50.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/lib/jboss-jmx.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/lib/jboss-system.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/server/default/lib/jboss.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/server/default/lib/jboss-ejb3x.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/server/default/deploy/ejb3.deployer/jboss-annotations-ejb3.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/server/default/deploy/ejb3.deployer/jboss-ejb3.jar"/>
+<archive
path="/home/tdiesler/svn/jbossas/branches/Branch_4_2/build/output/jboss-4.2.0.GA/server/default/deploy/jboss-aop-jdk50.deployer/jboss-aop-jdk50.jar"/>
</library>
<library name="jboss-5.0.x" systemlibrary="false">
<archive
path="/home/tdiesler/svn/jbossas/trunk/build/output/jboss-5.0.0.Beta2/lib/jboss-aop-jdk50.jar"/>
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-16
10:31:31 UTC (rev 2877)
+++
trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2007-04-16
12:28:34 UTC (rev 2878)
@@ -23,8 +23,11 @@
// $Id$
+import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Proxy;
import java.net.URL;
+import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -39,6 +42,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;
@@ -107,6 +111,21 @@
usRef = ServiceObjectFactoryJAXWS.getServiceRefAssociation();
UnifiedVirtualFile vfsRoot = (usRef != null ? vfsRoot = 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;
+ }
+ }
+
if (wsdlURL != null)
{
JAXWSClientMetaDataBuilder builder = new JAXWSClientMetaDataBuilder();
@@ -155,33 +174,26 @@
if (serviceMetaData == null)
throw new WebServiceException("Service meta data not available");
- // com/sun/ts/tests/jaxws/api/javax_xml_ws/Service
- // GetPort1NegTest1WithWsdl_from_wsappclient
+ // com/sun/ts/tests/jaxws/api/javax_xml_ws/Service#GetPort1NegTest1WithWsdl
EndpointMetaData epMetaData = serviceMetaData.getEndpoint(portName);
- if (epMetaData == null)
+ if (serviceMetaData.getEndpoints().size() > 0 && epMetaData == null)
throw new WebServiceException("Cannot get port meta data for: " +
portName);
+ // This is the case when the service could not be created from wsdl
+ if (serviceMetaData.getEndpoints().size() == 0)
+ {
+ log.warn("Cannot get port meta data for: " + portName);
+
+ 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;
- }
-
/**
* The getPort method returns a stub. A service client uses this stub to invoke
operations on the target service endpoint.
* The serviceEndpointInterface specifies the service endpoint interface that is
supported by the created dynamic proxy or stub instance.
@@ -222,6 +234,24 @@
return getPortInternal(epMetaData, seiClass);
}
+ private <T> QName getPortTypeName(Class<T> seiClass)
+ {
+ if (!seiClass.isAnnotationPresent(WebService.class))
+ throw new IllegalArgumentException("Cannot find @WebService on: " +
seiClass.getName());
+
+ 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;
+ }
+
private <T> T getPortInternal(EndpointMetaData epMetaData, Class<T>
seiClass)
{
QName portName = epMetaData.getPortName();
@@ -349,12 +379,26 @@
private <T> T createProxy(Class<T> seiClass, EndpointMetaData epMetaData)
throws WebServiceException
{
+ if (seiClass == null)
+ throw new IllegalArgumentException("SEI class cannot be null");
+
try
{
ExecutorService executor = (ExecutorService)getExecutor();
ClientProxy handler = new ClientProxy(executor, new ClientImpl(epMetaData,
handlerResolver));
ClassLoader cl = epMetaData.getClassLoader();
- T proxy = (T)Proxy.newProxyInstance(cl, new Class[] { seiClass,
BindingProvider.class, StubExt.class }, handler);
+
+ T proxy;
+ try
+ {
+ proxy = (T)Proxy.newProxyInstance(cl, new Class[] { seiClass,
BindingProvider.class, StubExt.class }, handler);
+ }
+ catch (RuntimeException rte)
+ {
+ URL codeLocation =
seiClass.getProtectionDomain().getCodeSource().getLocation();
+ log.error("Cannot create proxy for SEI " + seiClass.getName() +
" from: " + codeLocation);
+ throw rte;
+ }
// Configure the stub
configureStub((StubExt)proxy);
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/TestEndpointService.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/TestEndpointService.java 2007-04-16
10:31:31 UTC (rev 2877)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/TestEndpointService.java 2007-04-16
12:28:34 UTC (rev 2878)
@@ -15,7 +15,7 @@
* Generated source version: 2.0
*
*/
-@WebServiceClient(name = "TestEndpointService", targetNamespace =
"http://org.jboss.ws/wsref", wsdlLocation =
"http://localhost.localdomain:8080/jaxws-samples-webserviceref?wsdl")
+@WebServiceClient(name = "TestEndpointService", targetNamespace =
"http://org.jboss.ws/wsref", wsdlLocation =
"file://bogus-location/jaxws-samples-webserviceref?wsdl")
public class TestEndpointService
extends Service
{
@@ -27,7 +27,7 @@
static {
URL url = null;
try {
- url = new
URL("http://localhost.localdomain:8080/jaxws-samples-webserviceref?wsdl");
+ url = new
URL("file://bogus-location/jaxws-samples-webserviceref?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefClientTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefClientTestCase.java 2007-04-16
10:31:31 UTC (rev 2877)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefClientTestCase.java 2007-04-16
12:28:34 UTC (rev 2878)
@@ -21,10 +21,10 @@
*/
package org.jboss.test.ws.jaxws.samples.webserviceref;
-import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import junit.framework.Test;
@@ -32,8 +32,6 @@
import org.jboss.ejb3.client.ClientLauncher;
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
/**
* Test the JAXWS annotation: javax.xml.ws.WebServiceref
@@ -50,12 +48,18 @@
return JBossWSTestSetup.newTestSetup(WebServiceRefClientTestCase.class,
"jaxws-samples-webserviceref.war, jaxws-samples-webserviceref-client.jar");
}
- public void testWSDLAccess() throws MalformedURLException
+ public void testGeneratedService() throws Exception
{
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
- WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
- assertNotNull(wsdlDefinitions);
+ TestEndpointService service = new TestEndpointService();
+ TestEndpoint port = service.getTestEndpointPort();
+
+ // Set the target endpoint address, since the service could not be created from
wsdl
+ BindingProvider provider = (BindingProvider)port;
+ provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
TARGET_ENDPOINT_ADDRESS);
+
+ String helloWorld = "Hello World!";
+ Object retObj = port.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
}
public void testDynamicProxy() throws Exception
@@ -74,8 +78,8 @@
{
String helloWorld = "Hello World!";
TestEndpointClientOne.iniCtx = getInitialContext();
-
- new ClientLauncher().launch(TestEndpointClientOne.class.getName(),
"jbossws-client", new String[]{helloWorld});
+
+ new ClientLauncher().launch(TestEndpointClientOne.class.getName(),
"jbossws-client", new String[] { helloWorld });
assertEquals(helloWorld, TestEndpointClientOne.retStr);
}
}
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java 2007-04-16
10:31:31 UTC (rev 2877)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java 2007-04-16
12:28:34 UTC (rev 2878)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.ws.jaxws.samples.webserviceref;
-import java.net.MalformedURLException;
import java.net.URL;
import javax.naming.InitialContext;
@@ -32,8 +31,6 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
/**
* Test the JAXWS annotation: javax.xml.ws.WebServiceref
@@ -44,20 +41,12 @@
public class WebServiceRefEJB3TestCase extends JBossWSTest
{
public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-samples-webserviceref";
-
+
public static Test suite()
{
return JBossWSTestSetup.newTestSetup(WebServiceRefEJB3TestCase.class,
"jaxws-samples-webserviceref.war");
}
- public void testWSDLAccess() throws MalformedURLException
- {
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
- WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
- assertNotNull(wsdlDefinitions);
- }
-
public void testDynamicProxy() throws Exception
{
URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
Modified:
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java
===================================================================
---
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java 2007-04-16
10:31:31 UTC (rev 2877)
+++
trunk/jbossws-tests/src/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java 2007-04-16
12:28:34 UTC (rev 2878)
@@ -23,7 +23,6 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
-import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
@@ -33,8 +32,6 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
/**
* Test the JAXWS annotation: javax.xml.ws.WebServiceref
@@ -45,20 +42,12 @@
public class WebServiceRefServletTestCase extends JBossWSTest
{
public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-samples-webserviceref";
-
+
public static Test suite()
{
return JBossWSTestSetup.newTestSetup(WebServiceRefServletTestCase.class,
"jaxws-samples-webserviceref.war");
}
- public void testWSDLAccess() throws MalformedURLException
- {
- URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
- WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
- assertNotNull(wsdlDefinitions);
- }
-
public void testDynamicProxy() throws Exception
{
URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");