cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r506507 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/common/util/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/jaxws/src/main...
Date Mon, 12 Feb 2007 15:50:01 GMT
Author: dandiep
Date: Mon Feb 12 07:50:00 2007
New Revision: 506507

URL: http://svn.apache.org/viewvc?view=rev&rev=506507
Log:
Apply CXF-324 to fix WSDL generation. Thanks Jarek! Also, I added a wsdlLocation property
into the jaxws.xsd, but it doesn't work yet. I'm going to have to make further changes to
EndpointImpl to make this possible.

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
  (with props)
Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/org/apache/cxf/jaxws/spring/jaxws.xsd
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBeanTest.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/PackageUtils.java
Mon Feb 12 07:50:00 2007
@@ -177,5 +177,31 @@
     private static boolean contiansReservedKeywords(String token) {
         return KEYWORDS.contains(token);
     }
+
+    public static String getNamespace(String packageName) {
+        if (packageName == null || packageName.length() == 0) {
+            return null;
+        }
+        StringTokenizer tokenizer = new StringTokenizer(packageName, ".");
+        String[] tokens;
+        if (tokenizer.countTokens() == 0) {
+            tokens = new String[0];
+        } else {
+            tokens = new String[tokenizer.countTokens()];
+            for (int i = tokenizer.countTokens() - 1; i >= 0; i--) {
+                tokens[i] = tokenizer.nextToken();
+            }
+        }
+        StringBuffer namespace = new StringBuffer("http://");
+        String dot = "";
+        for (int i = 0; i < tokens.length; i++) {
+            if (i == 1) {
+                dot = ".";
+            }
+            namespace.append(dot + tokens[i]);
+        }
+        namespace.append('/');
+        return namespace.toString();
+    }
     
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointFactoryBean.java
Mon Feb 12 07:50:00 2007
@@ -48,6 +48,7 @@
     private ApplicationContext context;
     private String binding;
     private Map<String, Object> properties;
+    private String wsdlLocation;
     
     public void setApplicationContext(ApplicationContext c) 
         throws BeansException {
@@ -160,4 +161,13 @@
     public void setServiceFactory(AbstractJaxWsServiceFactoryBean serviceFactory) {
         this.serviceFactory = serviceFactory;
     }
+
+    public String getWsdlLocation() {
+        return wsdlLocation;
+    }
+
+    public void setWsdlLocation(String wsdlLocation) {
+        this.wsdlLocation = wsdlLocation;
+    }
+    
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
Mon Feb 12 07:50:00 2007
@@ -36,6 +36,7 @@
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxb.JAXBEncoderDecoder;
 
@@ -93,18 +94,22 @@
         if (implementorAnnotation != null) {
             serviceName = implementorAnnotation.serviceName();
             namespace = implementorAnnotation.targetNamespace();
-        } else {
-            // Must be a provider
+        } else if (wsProviderAnnotation != null) {
             serviceName = wsProviderAnnotation.serviceName();
             namespace = wsProviderAnnotation.targetNamespace();
+        } else {
+            return null;
         }
+
         if (StringUtils.isEmpty(serviceName)) {
-            serviceName = implementorClass.getName();
+            serviceName = implementorClass.getSimpleName() + "Service";
         }
-        if (!StringUtils.isEmpty(namespace) && !StringUtils.isEmpty(serviceName))
{
-            return new QName(namespace, serviceName);
+
+        if (StringUtils.isEmpty(namespace)) {
+            namespace = getDefaultNamespace(implementorClass);
         }
-        return null;
+
+        return new QName(namespace, serviceName);
     }
 
     /**
@@ -118,21 +123,64 @@
         if (implementorAnnotation != null) {
             portName = implementorAnnotation.portName();
             namespace = implementorAnnotation.targetNamespace();
-        } else {
-            // Must be a provider
+        } else if (wsProviderAnnotation != null) {
             portName = wsProviderAnnotation.portName();
             namespace = wsProviderAnnotation.targetNamespace();
+        } else {
+            return null;
         }
 
         if (StringUtils.isEmpty(portName)) {
             portName = implementorClass.getSimpleName() + "Port";
         }
 
-        if (!StringUtils.isEmpty(portName)) {
-            return new QName(namespace, portName);
+        if (StringUtils.isEmpty(namespace)) {
+            namespace = getDefaultNamespace(implementorClass);
+        }
+
+        return new QName(namespace, portName);
+    }
+
+    public QName getInterfaceName() {
+        String name = null;
+        String namespace = null;
+
+        if (seiAnnotation != null) {
+            if (StringUtils.isEmpty(seiAnnotation.name())) {
+                name = seiClass.getSimpleName();
+            } else {
+                name = seiAnnotation.name();
+            }
+            if (StringUtils.isEmpty(seiAnnotation.targetNamespace())) {
+                namespace = getDefaultNamespace(seiClass);
+            } else {
+                namespace = seiAnnotation.targetNamespace();
+            }
+        } else if (implementorAnnotation != null) {
+            if (StringUtils.isEmpty(implementorAnnotation.name())) {
+                name = implementorClass.getSimpleName();
+            } else {
+                name = implementorAnnotation.name();
+            }
+            if (StringUtils.isEmpty(implementorAnnotation.targetNamespace())) {
+                namespace = getDefaultNamespace(implementorClass);
+            } else {
+                namespace = implementorAnnotation.targetNamespace();
+            }
         } else {
-            return new QName(namespace, "NoNamedPort");
-        }        
+            return null;
+        }
+        
+        return new QName(namespace, name);
+    }
+
+    private String getDefaultNamespace(Class clazz) {
+        Package pkg = clazz.getPackage();
+        if (pkg == null) {
+            return null;
+        } else {
+            return PackageUtils.getNamespace(pkg.getName());
+        }
     }
         
     @SuppressWarnings("unchecked")

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Mon Feb 12 07:50:00 2007
@@ -63,40 +63,24 @@
         implInfo = ((JaxWsServiceFactoryBean)serviceFactory).getJaxWsImplementorInfo();
     }
 
-    WebService getConcreteWebServiceAttribute() {
-        return getServiceFactory().getServiceClass().getAnnotation(WebService.class);
-    }
-
-    WebService getPortTypeWebServiceAttribute() {
-        Class<?> epi = implInfo.getEndpointClass();
-        WebService ws = null;
-        if (epi != null) {
-            ws = epi.getAnnotation(WebService.class);
-        }
-        if (ws == null) {
-            ws = getConcreteWebServiceAttribute();
-        }
-        return ws;
-    }
-
     @Override
     public String getServiceName() {
-        WebService ws = getConcreteWebServiceAttribute();
-        if (ws != null && ws.serviceName().length() > 0) {
-            return ws.serviceName();
+        QName service = implInfo.getServiceName();
+        if (service == null) {
+            return null;
+        } else {
+            return service.getLocalPart();
         }
-
-        return null;
     }
 
     @Override
     public String getServiceNamespace() {
-        WebService ws = getConcreteWebServiceAttribute();
-        if (ws != null && ws.targetNamespace().length() > 0) {
-            return ws.targetNamespace();
+        QName service = implInfo.getServiceName();
+        if (service == null) {
+            return null;
+        } else {
+            return service.getNamespaceURI();
         }
-
-        return null;
     }
 
     @Override
@@ -105,19 +89,24 @@
     }
 
     @Override
+    public QName getInterfaceName() {
+        return implInfo.getInterfaceName();
+    }
+
+    @Override
     public URL getWsdlURL() {
-        WebService ws = getPortTypeWebServiceAttribute();
-        if (ws != null && ws.wsdlLocation().length() > 0) {
+        String wsdlLocation = implInfo.getWsdlLocation();
+        if (wsdlLocation != null && wsdlLocation.length() > 0) {
             try {
-                URIResolver resolver = new URIResolver(null, ws.wsdlLocation(), getClass());
+                URIResolver resolver = new URIResolver(null, wsdlLocation, getClass());
                 if (resolver.isResolved()) {
                     return resolver.getURI().toURL();
                 } else {
-                    throw new WebServiceException("Could not find WSDL with URL " + ws.wsdlLocation());
+                    throw new WebServiceException("Could not find WSDL with URL " + wsdlLocation);
                 }
             } catch (IOException e) {
                 throw new ServiceConstructionException(
-                    new Message("LOAD_WSDL_EXC", BUNDLE, ws.wsdlLocation()), e);
+                    new Message("LOAD_WSDL_EXC", BUNDLE, wsdlLocation), e);
             }
         }
         return null;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Mon Feb 12 07:50:00 2007
@@ -56,7 +56,7 @@
     public JaxWsServiceFactoryBean(JaxWsImplementorInfo implInfo) {
         this();
         setJaxWsImplementorInfo(implInfo);
-        this.serviceClass = implInfo.getImplementorClass();
+        this.serviceClass = implInfo.getEndpointClass();
     }
 
     @Override

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBean.java
Mon Feb 12 07:50:00 2007
@@ -128,7 +128,7 @@
             
             EndpointInfo ei = new EndpointInfo(si, bindingURI);
             ei.setBinding(bi);
-            ei.setName(new QName(getServiceName() + "Port"));
+            ei.setName(getEndpointName());
             si.addEndpoint(ei);
         } else if ("soapns".equals(bindingURI)) {
             // TODO

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/WebServiceProviderConfiguration.java
Mon Feb 12 07:50:00 2007
@@ -25,7 +25,6 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceException;
-import javax.xml.ws.WebServiceProvider;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
@@ -38,29 +37,32 @@
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(WebServiceProviderConfiguration.class);
 
     private JaxWsImplementorInfo implInfo;
-    private WebServiceProvider wsProvider;
     
     @Override
     public void setServiceFactory(ReflectionServiceFactoryBean serviceFactory) {
         super.setServiceFactory(serviceFactory);
         implInfo = ((ProviderServiceFactoryBean) serviceFactory).getJaxWsImplementorInfo();
-        wsProvider = implInfo.getWsProvider();
     }
 
+
     @Override
     public String getServiceName() {
-        if (wsProvider.serviceName().length() > 0) {
-            return wsProvider.serviceName();
+        QName service = implInfo.getServiceName();
+        if (service == null) {
+            return null;
+        } else {
+            return service.getLocalPart();
         }
-        return null;
     }
 
     @Override
     public String getServiceNamespace() {
-        if (wsProvider.targetNamespace().length() > 0) {
-            return wsProvider.targetNamespace();
+        QName service = implInfo.getServiceName();
+        if (service == null) {
+            return null;
+        } else {
+            return service.getNamespaceURI();
         }
-        return null;
     }
 
     @Override
@@ -70,20 +72,18 @@
 
     @Override
     public URL getWsdlURL() {
-        String loc = wsProvider.wsdlLocation();
-        if (loc.length() > 0) {
+        String wsdlLocation = implInfo.getWsdlLocation();
+        if (wsdlLocation != null && wsdlLocation.length() > 0) {
             try {
-                URIResolver resolver = new URIResolver(null, loc, getClass());
+                URIResolver resolver = new URIResolver(null, wsdlLocation, getClass());
                 if (resolver.isResolved()) {
                     return resolver.getURI().toURL();
                 } else {
-                    throw new WebServiceException("Could not find WSDL with URL " + loc);
+                    throw new WebServiceException("Could not find WSDL with URL " + wsdlLocation);
                 }
             } catch (IOException e) {
-                throw new ServiceConstructionException(new Message("LOAD_WSDL_EXC", 
-                                                                   BUNDLE, 
-                                                                   loc),
-                                                       e);
+                throw new ServiceConstructionException(
+                    new Message("LOAD_WSDL_EXC", BUNDLE, wsdlLocation), e);
             }
         }
         return null;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/org/apache/cxf/jaxws/spring/jaxws.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/org/apache/cxf/jaxws/spring/jaxws.xsd?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/org/apache/cxf/jaxws/spring/jaxws.xsd
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/org/apache/cxf/jaxws/spring/jaxws.xsd
Mon Feb 12 07:50:00 2007
@@ -27,6 +27,7 @@
           <xsd:attribute name="publish" type="xsd:boolean" default="true"/>
           <xsd:attribute name="portName" type="xsd:QName" />
           <xsd:attribute name="serviceName" type="xsd:QName" />
+          <xsd:attribute name="wsdlLocation" type="xsd:string" />
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>
@@ -51,6 +52,7 @@
           <xsd:attribute name="serviceBean" type="xsd:string"/>
           <xsd:attribute name="start" type="xsd:boolean" default="true"/>
           <xsd:attribute name="transportId" type="xsd:string"/>
+          <xsd:attribute name="wsdlLocation" type="xsd:string" />
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
Mon Feb 12 07:50:00 2007
@@ -52,9 +52,9 @@
         Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(d);
         addNamespace("svc", "http://service.jaxws.cxf.apache.org/");
         
-        assertValid("/wsdl:definitions/wsdl:service[@name='Hello']", wsdl);
+        assertValid("/wsdl:definitions/wsdl:service[@name='HelloService']", wsdl);
         assertValid("//wsdl:port/wsdlsoap:address[@location='" + address + "']", wsdl);
-        assertValid("//wsdl:portType[@name='HelloPortType']", wsdl);
+        assertValid("//wsdl:portType[@name='Hello']", wsdl);
         assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']"
                     + "/wsdl:part[@type='xsd:string'][@name='text']",
                     wsdl);
@@ -67,9 +67,9 @@
         
         addNamespace("svc", "http://service.jaxws.cxf.apache.org");
         
-        assertValid("/wsdl:definitions/wsdl:service[@name='Hello']", wsdl);
+        assertValid("/wsdl:definitions/wsdl:service[@name='HelloService']", wsdl);
         assertValid("//wsdl:port/wsdlsoap:address[@location='" + address + "']", wsdl);
-        assertValid("//wsdl:portType[@name='HelloPortType']", wsdl);
+        assertValid("//wsdl:portType[@name='Hello']", wsdl);
         assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']"
                     + "/wsdl:part[@element='ns1:sayHi'][@name='sayHi']",
                     wsdl);

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java?view=auto&rev=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
Mon Feb 12 07:50:00 2007
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws;
+
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.service.Hello2;
+import org.apache.cxf.jaxws.service.Hello3;
+import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+
+public class CodeFirstWSDLTest extends AbstractJaxWsTest {
+    String address = "local://localhost:9000/Hello";
+    
+    private Definition createService(Class clazz) throws Exception {
+        
+        JaxWsImplementorInfo info = new JaxWsImplementorInfo(clazz);
+        ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(info);
+
+        Bus bus = getBus();
+        bean.setBus(bus);
+        
+        Service service = bean.create();
+
+        InterfaceInfo i = service.getServiceInfo().getInterface();
+        assertEquals(2, i.getOperations().size());
+
+        ServerFactoryBean svrFactory = new ServerFactoryBean();
+        svrFactory.setBus(bus);
+        svrFactory.setServiceFactory(bean);
+        svrFactory.setAddress(address);
+        svrFactory.create();
+        
+        Collection<BindingInfo> bindings = service.getServiceInfo().getBindings();
+        assertEquals(1, bindings.size());
+        
+        ServiceWSDLBuilder wsdlBuilder = 
+            new ServiceWSDLBuilder(service.getServiceInfo());
+        return wsdlBuilder.build();
+    }
+
+    public void testWSDL1() throws Exception {
+        Definition d = createService(Hello2.class);
+
+        QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "Hello2Service");
+
+        javax.wsdl.Service service = d.getService(serviceName);
+
+        assertNotNull(service);
+
+        QName portName = new QName("http://service.jaxws.cxf.apache.org/", "Hello2Port");
+
+        javax.wsdl.Port port = service.getPort(portName.getLocalPart());
+
+        assertNotNull(port);
+
+        QName portTypeName = new QName("http://service.jaxws.cxf.apache.org/", "HelloInterface");
+
+        javax.wsdl.PortType portType = d.getPortType(portTypeName);
+
+        assertNotNull(portType);
+        assertEquals(2, portType.getOperations().size());
+    }
+
+    public void testWSDL2() throws Exception {
+        Definition d = createService(Hello3.class);
+
+        QName serviceName = new QName("http://mynamespace.com/", "MyService");
+
+        javax.wsdl.Service service = d.getService(serviceName);
+
+        assertNotNull(service);
+
+        QName portName = new QName("http://mynamespace.com/", "MyPort");
+
+        javax.wsdl.Port port = service.getPort(portName.getLocalPart());
+
+        assertNotNull(port);
+
+        QName portTypeName = new QName("http://service.jaxws.cxf.apache.org/", "HelloInterface");
+
+        javax.wsdl.PortType portType = d.getPortType(portTypeName);
+
+        assertNotNull(portType);
+        assertEquals(2, portType.getOperations().size());
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java?view=auto&rev=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
Mon Feb 12 07:50:00 2007
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = "org.apache.cxf.jaxws.service.HelloInterface")
+public class Hello2 implements HelloInterface {
+
+    public String sayHi(String text) {
+        return text;
+    }
+    
+    public List<String> getGreetings() {
+        List<String> strings = new ArrayList<String>();
+        strings.add("Hello");
+        strings.add("Bonjour");
+        return strings;
+    }
+
+    public void sayGoodbye() {
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java?view=auto&rev=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
Mon Feb 12 07:50:00 2007
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "MyService", 
+            portName = "MyPort",
+            targetNamespace = "http://mynamespace.com/",
+            endpointInterface = "org.apache.cxf.jaxws.service.HelloInterface")
+public class Hello3 implements HelloInterface {
+
+    public String sayHi(String text) {
+        return text;
+    }
+    
+    public List<String> getGreetings() {
+        List<String> strings = new ArrayList<String>();
+        strings.add("Hello");
+        strings.add("Bonjour");
+        return strings;
+    }
+
+    public void sayGoodbye() {
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
Mon Feb 12 07:50:00 2007
@@ -27,7 +27,7 @@
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class SpringBeansTest extends TestCase {
-    public void xtestEndpoints() throws Exception {
+    public void testEndpoints() throws Exception {
         ClassPathXmlApplicationContext ctx = 
             new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxws/spring/endpoints.xml"});
 
@@ -64,6 +64,9 @@
         
         ep = (EndpointImpl) bean;
         assertTrue(ep.getImplementor() instanceof Hello);
+        
+        bean = ctx.getBean("wsdlLocation");
+        assertNotNull(bean);
     }
     
     public void testServers() throws Exception {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
Mon Feb 12 07:50:00 2007
@@ -62,5 +62,9 @@
   
   <jaxws:endpoint id="classImpl" 
     implementor="org.apache.cxf.jaxws.service.Hello"
-    address="http://localhost:8080/test"/>
+    address="http://localhost:8080/test"/>
+    
+  <jaxws:endpoint id="wsdlLocation" 
+    implementor="#greeter" address="http://localhost:8080/simpleWithAddress"
+    wsdlLocation="wsdl/hello_world.wsdl"/>
 </beans>

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBeanTest.java?view=diff&rev=506507&r1=506506&r2=506507
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBeanTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ProviderServiceFactoryBeanTest.java
Mon Feb 12 07:50:00 2007
@@ -82,14 +82,15 @@
 
         Service service = bean.create();
 
-        assertEquals("SourcePayloadProvider", service.getName().getLocalPart());
+        assertEquals("SourcePayloadProviderService", service.getName().getLocalPart());
         
         InterfaceInfo intf = service.getServiceInfo().getInterface();
         assertNotNull(intf);
         
         assertEquals(1, service.getServiceInfo().getEndpoints().size());
         
-        EndpointInfo ei = service.getServiceInfo().getEndpoint(new QName("SourcePayloadProviderPort"));
+        QName portName = new QName("http://support.jaxws.cxf.apache.org/", "SourcePayloadProviderPort");
+        EndpointInfo ei = service.getServiceInfo().getEndpoint(portName);
         
         assertNotNull(ei);
         



Mime
View raw message