You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2009/07/07 10:49:03 UTC

svn commit: r791753 - in /cxf/trunk: rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/ systests/src/test/java/org/apache/cxf/systest/xmlbeans/

Author: ffang
Date: Tue Jul  7 08:49:02 2009
New Revision: 791753

URL: http://svn.apache.org/viewvc?rev=791753&view=rev
Log:
[CXF-2322] can't publish endpoint with XmlBeans databinding when build servicemodel from class

Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml
Modified:
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java?rev=791753&r1=791752&r2=791753&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java (original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java Tue Jul  7 08:49:02 2009
@@ -196,8 +196,11 @@
             
             SchemaTypeSystem sts = st.getTypeSystem();
             schemas.getXmlSchemaCollection().setSchemaResolver(new XMLSchemaResolver(sts));
-
-            XmlSchema schema = getSchema(sts, st.getSourceName());
+            String sourceName = st.getSourceName();
+            if (sourceName.endsWith("wsdl")) {
+                return;
+            }
+            XmlSchema schema = getSchema(sts, sourceName);
 
             if (st.isDocumentType()) {
                 XmlSchemaElement sct = schema.getElementByName(st.getDocumentElementName());

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java?rev=791753&r1=791752&r2=791753&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ClientServerXmlBeansTest.java Tue Jul  7 08:49:02 2009
@@ -23,11 +23,15 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPBinding;
 
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.helloWorldSoapHttp.xmlbeans.types.FaultDetailDocument;
 import org.apache.helloWorldSoapHttp.xmlbeans.types.FaultDetailDocument.FaultDetail;
@@ -48,6 +52,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
+        assertTrue("server did not launch correctly", launchServer(ServerNoWsdl.class, true));
     }
     
     @Test
@@ -61,7 +66,51 @@
         SOAPService ss = new SOAPService(wsdl, SERVICE_NAME);
         Greeter port = ss.getSoapPort();
         String resp; 
+        ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor());
+        ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor());
+        resp = port.sayHi();
+        assertEquals("We should get the right response", resp, "Bonjour");        
+        
+        resp = port.greetMe("Willem");
+        assertEquals("We should get the right response", resp, "Hello Willem");
+        
+        try {
+            resp = port.greetMe("Invoking greetMe with invalid length string, expecting exception...");
+            fail("We expect exception here");
+        } catch (WebServiceException ex) {           
+            assertTrue("Get a wrong exception", 
+                       ex.getMessage().
+                       indexOf("string length (67) is greater than maxLength facet (30)") >= 0);
+        }
         
+        port.greetMeOneWay(System.getProperty("user.name"));
+        
+        try {
+            port.pingMe();
+            fail("We expect exception here");
+        } catch (PingMeFault ex) {            
+            FaultDetailDocument detailDocument = ex.getFaultInfo();
+            FaultDetail detail = detailDocument.getFaultDetail();
+            assertEquals("Wrong faultDetail major", detail.getMajor(), 2);
+            assertEquals("Wrong faultDetail minor:", detail.getMinor(), 1);             
+        }          
+    }
+    
+    @Test
+    public void testCallFromClientNoWsdlServer() throws Exception {
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus("org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml");
+        BusFactory.setDefaultBus(bus);
+        URL wsdl = this.getClass().getResource("/wsdl_systest/xmlbeans/hello_world.wsdl");
+        assertNotNull("We should found the WSDL her. " , wsdl);      
+        
+        SOAPService ss = new SOAPService(wsdl, SERVICE_NAME);
+        QName soapPort = new QName("http://apache.org/hello_world_soap_http/xmlbeans", "SoapPort");
+        ss.addPort(soapPort, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:9010/SoapContext/SoapPort");
+        Greeter port = ss.getPort(soapPort, Greeter.class);
+        String resp; 
+        ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor());
+        ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor());
         resp = port.sayHi();
         assertEquals("We should get the right response", resp, "Bonjour");        
         

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java?rev=791753&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/ServerNoWsdl.java Tue Jul  7 08:49:02 2009
@@ -0,0 +1,54 @@
+/**
+ * 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.systest.xmlbeans;
+
+import javax.xml.ws.Endpoint;
+
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class ServerNoWsdl extends AbstractBusTestServerBase {
+
+    protected void run() {
+        // set the configuration file
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus("org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml");
+        BusFactory.setDefaultBus(bus);
+        setBus(bus);
+        Object implementor = new GreeterImpl();
+        String address = "http://localhost:9010/SoapContext/SoapPort";
+        Endpoint.publish(address, implementor);
+    }
+
+    public static void main(String args[]) {
+        try {
+            ServerNoWsdl s = new ServerNoWsdl();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml?rev=791753&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml Tue Jul  7 08:49:02 2009
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:jaxws="http://cxf.apache.org/jaxws"
+      xmlns:cxf="http://cxf.apache.org/core"
+      xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+    <!-- comment this bean to disable schema validation in the client -->
+
+    <jaxws:client name="{http://apache.org/hello_world_soap_http/xmlbeans}SoapPort"
+        createdFromAPI="true">
+        <!-- jaxws:properties>
+            <entry key="schema-validation-enabled" value="true" />
+        </jaxws:properties-->
+        <jaxws:dataBinding>
+        	<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
+        </jaxws:dataBinding>
+    </jaxws:client>
+
+    <jaxws:endpoint name="{http://apache.org/hello_world_soap_http/xmlbeans}SoapPort"
+        createdFromAPI="true">
+        <jaxws:properties>
+            <entry key="schema-validation-enabled" value="true" />
+        </jaxws:properties>
+        <jaxws:dataBinding>
+        	<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
+        </jaxws:dataBinding>
+    </jaxws:endpoint>
+
+</beans>
+