cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r442512 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/wsdl/ rt/core/src/main/java/org/apache/cxf/service/factory/ rt/core/src/main/java/org/apache/cxf/wsdl11/ systests/src/test/java/org/apache/cxf/systest/callback/
Date Tue, 12 Sep 2006 08:11:33 GMT
Author: ffang
Date: Tue Sep 12 01:11:32 2006
New Revision: 442512

URL: http://svn.apache.org/viewvc?view=rev&rev=442512
Log:
[JIRA CXF-67] get callback working - porting callback system test framework


Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
  (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?view=diff&rev=442512&r1=442511&r2=442512
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Tue Sep 12 01:11:32 2006
@@ -48,6 +48,7 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -640,4 +641,6 @@
     private static String getService(String content) {
         return content.substring(content.indexOf(":") + 1, content.length());
     }    
+    
+    
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=442512&r1=442511&r2=442512
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Tue Sep 12 01:11:32 2006
@@ -139,7 +139,9 @@
                 if (isValidMethod(m)) {
                     QName opName = getOperationName(intf, m);
 
-                    if (o.getName().equals(opName)) {
+                    if (o.getName().getNamespaceURI().equals(opName.getNamespaceURI())
+                        && isMatchOperation(o.getName().getLocalPart(), opName.getLocalPart()))
{
+                    //if (o.getName().equals(opName)) {
                         selected = m;
                         o.setProperty(Method.class.getName(), m);
                         break;
@@ -305,6 +307,18 @@
         return true;
     }
 
+    protected boolean isMatchOperation(String methodNameInClass, String methodNameInWsdl)
{
+        boolean ret = false;
+        String initOfMethodInClass = methodNameInClass.substring(0, 1);
+        String initOfMethodInWsdl = methodNameInWsdl.substring(0, 1);
+        if (initOfMethodInClass.equalsIgnoreCase(initOfMethodInWsdl)
+            && methodNameInClass.substring(1, methodNameInClass.length()).equals(
+                methodNameInWsdl.substring(1, methodNameInWsdl.length()))) {
+            ret = true;
+        }
+        return ret;
+    }
+    
     protected boolean isOutParam(Method method, int j) {
         for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
             AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
@@ -556,4 +570,6 @@
     public void setExecutor(Executor executor) {
         this.executor = executor;
     }
+    
+    
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=442512&r1=442511&r2=442512
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Tue Sep 12 01:11:32 2006
@@ -186,6 +186,7 @@
                     }
                 }
                 if (schemaElem != null) {
+                    schemaCol.setBaseUri(def.getDocumentBaseURI());
                     XmlSchema xmlSchema = schemaCol.read(schemaElem);
                     SchemaInfo schemaInfo = new SchemaInfo(typeInfo, xmlSchema.getTargetNamespace());
                     schemaInfo.setElement(schemaElem);

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java?view=auto&rev=442512
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
Tue Sep 12 01:11:32 2006
@@ -0,0 +1,83 @@
+/**
+ * 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.callback;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.callback.SOAPService;
+import org.apache.callback.ServerPortType;
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
+
+public class CallbackClientServerTest extends ClientServerTestBase {
+    private static final QName SERVICE_NAME 
+        = new QName("http://apache.org/callback", "SOAPService");
+
+
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(CallbackClientServerTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly", launchServer(Server.class));
+            }
+        };
+        
+    }
+
+    public void xtestCallback() {
+
+                    
+        Object implementor = new CallbackImpl();
+        String address = "http://localhost:9005/CallbackContext/CallbackPort";
+        Endpoint.publish(address, implementor);
+    
+        URL wsdlURL = getClass().getResource("/wsdl/basic_callback.wsdl");
+    
+        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
+        ServerPortType port = ss.getSOAPPort();
+   
+        EndpointReferenceType ref = null;
+        try {
+            ref = EndpointReferenceUtils.getEndpointReference(new WSDLManagerImpl(), implementor);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    
+        String resp = port.registerCallback(ref);
+
+        assertEquals("registerCallback called", resp);
+            
+    }
+    
+    public void testDummyCallback() throws Exception {
+        assertTrue(true);
+    }
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackClientServerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java?view=auto&rev=442512
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java
Tue Sep 12 01:11:32 2006
@@ -0,0 +1,45 @@
+/**
+ * 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.callback;
+
+import org.apache.callback.CallbackPortType;
+
+
+@javax.jws.WebService(serviceName = "CallbackService", 
+                      portName = "CallbackPort",
+                      endpointInterface = "org.apache.callback.CallbackPortType",
+                      targetNamespace = "http://apache.org/callback") 
+                      //wsdlLocation = "file:./wsdl/basic_callback.wsdl")
+                  
+public class CallbackImpl implements CallbackPortType  {
+
+    //private static final Logger LOG = 
+    //    Logger.getLogger(CallbackImpl.class.getPackage().getName());
+    
+    /**
+     * serverSayHi
+     * @param: return_message (String)
+     * @return: String
+     */
+    public String serverSayHi(String message) {
+        return new String("Hi " + message);
+    }
+    
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/CallbackImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java?view=auto&rev=442512
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
Tue Sep 12 01:11:32 2006
@@ -0,0 +1,47 @@
+/**
+ * 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.callback;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.systest.common.TestServerBase;
+
+public class Server extends TestServerBase {
+
+    protected void run() {
+        Object implementor = new ServerImpl();
+        String address = "http://localhost:9007/SoapContext/SoapPort";
+        Endpoint.publish(address, implementor);
+    }
+
+    public static void main(String[] args) {
+        try { 
+            Server s = new Server(); 
+            s.start();
+            //s.run();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally { 
+            System.out.println("done!");
+        }
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/Server.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java?view=auto&rev=442512
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
Tue Sep 12 01:11:32 2006
@@ -0,0 +1,93 @@
+/**
+ * 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.callback;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.callback.CallbackPortType;
+import org.apache.callback.ServerPortType;
+import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
+
+@javax.jws.WebService(serviceName = "SOAPService", 
+                      portName = "SOAPPort",
+                      targetNamespace = "http://apache.org/callback",
+                      endpointInterface = "org.apache.callback.ServerPortType") 
+                      //wsdlLocation = "file:./wsdl/basic_callback.wsdl")
+                  
+public class ServerImpl implements ServerPortType  {
+
+    //private static final Logger LOG = 
+    //    Logger.getLogger(ServerImpl.class.getPackage().getName());
+    
+    public String foo(String s) {
+        return s;
+    }
+    
+    public String registerCallback(EndpointReferenceType callback) {
+        try {
+            WSDLManager manager = new WSDLManagerImpl();
+        
+            QName interfaceName = EndpointReferenceUtils.getInterfaceName(callback);
+            String wsdlLocation = EndpointReferenceUtils.getWSDLLocation(callback);
+            QName serviceName = EndpointReferenceUtils.getServiceName(callback);
+
+            
+            String portString = EndpointReferenceUtils.getPortName(callback);
+            
+            QName portName = new QName(serviceName.getNamespaceURI(), portString);
+            
+            StringBuffer seiName = new StringBuffer();
+            seiName.append(JAXBUtils.namespaceURIToPackage(interfaceName.getNamespaceURI()));
+            seiName.append(".");
+            seiName.append(JAXBUtils.nameToIdentifier(interfaceName.getLocalPart(),
+                                                      JAXBUtils.IdentifierType.INTERFACE));
+            
+            Class<?> sei = null; 
+            try {
+                sei = Class.forName(seiName.toString(), 
+                                    true, manager.getClass().getClassLoader());
+            } catch (ClassNotFoundException ex) {
+                ex.printStackTrace();
+            }
+            
+            URL wsdlURL = new URL(wsdlLocation);            
+            Service service = Service.create(wsdlURL, serviceName);
+            CallbackPortType port =  (CallbackPortType)service.getPort(portName, sei);
+
+            port.serverSayHi("Sean");
+
+            
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return null;
+        }
+        
+        return "registerCallback called";     
+    }
+    
+}    
\ No newline at end of file

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/callback/ServerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message