cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1373850 - in /cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ systests/transports/ systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/
Date Thu, 16 Aug 2012 14:14:17 GMT
Author: dkulp
Date: Thu Aug 16 14:14:16 2012
New Revision: 1373850

URL: http://svn.apache.org/viewvc?rev=1373850&view=rev
Log:
Add initial support for the SOAP-UDP spec

Added:
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/Server.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/SoapUDPTest.java
Modified:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
    cxf/trunk/systests/transports/pom.xml

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=1373850&r1=1373849&r2=1373850&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Thu Aug 16 14:14:16 2012
@@ -80,6 +80,7 @@ import org.apache.cxf.interceptor.Attach
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.BareOutInterceptor;
 import org.apache.cxf.interceptor.DocLiteralInInterceptor;
+import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.interceptor.StaxInInterceptor;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
 import org.apache.cxf.interceptor.URIMappingInterceptor;
@@ -89,6 +90,7 @@ import org.apache.cxf.service.model.Bind
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.MessageInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
@@ -97,6 +99,7 @@ import org.apache.cxf.transport.ChainIni
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.MultipleEndpointObserver;
+import org.apache.cxf.ws.addressing.WSAddressingFeature;
 import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.cxf.wsdl11.WSDLServiceBuilder;
 
@@ -327,6 +330,7 @@ public class SoapBindingFactory extends 
     public Binding createBinding(BindingInfo binding) {
         // TODO what about the mix style/use?
 
+
         // The default style should be doc-lit wrapped.
         String parameterStyle = SoapBindingConstants.PARAMETER_STYLE_WRAPPED;
         String bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;
@@ -435,10 +439,25 @@ public class SoapBindingFactory extends 
             sb.getInFaultInterceptors().add(new Soap12FaultInInterceptor());
             sb.getOutFaultInterceptors().add(new Soap12FaultOutInterceptor());
         }
+        
+        if (binding.getService() != null) {
+            for (EndpointInfo ei: binding.getService().getEndpoints()) {
+                if (ei.getAddress() != null && ei.getAddress().startsWith("soap.udp"))
{
+                    setupUDP(sb);
+                }
+            }
+        }
 
         return sb;
     }
 
+    protected void setupUDP(InterceptorProvider p) {
+        //soap UDP requires ws-addressing turned on
+        WSAddressingFeature add = new WSAddressingFeature();
+        add.setAddressingRequired(true);
+        add.initialize(p, bus);
+    }
+    
     protected void addMessageFromBinding(ExtensibilityElement ext, BindingOperationInfo bop,
                                          boolean isInput) {
         SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
@@ -832,6 +851,13 @@ public class SoapBindingFactory extends 
     @Override
     public synchronized void addListener(Destination d, Endpoint e) {
         MessageObserver mo = d.getMessageObserver();
+        if (d.getAddress() != null 
+            && d.getAddress().getAddress() != null 
+            && d.getAddress().getAddress().getValue() != null 
+            && d.getAddress().getAddress().getValue().startsWith("soap.udp")) {
+            //soap.udp REQUIRES usage of WS-Addressing... we need to turn this on
+            setupUDP(e);
+        }
         if (mo == null) {
             super.addListener(d, e);
             return;

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java?rev=1373850&r1=1373849&r2=1373850&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
Thu Aug 16 14:14:16 2012
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -77,6 +78,10 @@ public class SoapTransportFactory extend
             "http://www.w3.org/2010/soapjms/",
             "http://www.w3.org/2003/05/soap/bindings/HTTP/",
             "http://schemas.xmlsoap.org/soap/http");
+    public static final Set<String> DEFAULT_PREFIXES 
+        = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
+            "soap.udp", "soap.tcp"
+        )));
     
     public SoapTransportFactory() {
         super(DEFAULT_NAMESPACES, null);
@@ -87,12 +92,14 @@ public class SoapTransportFactory extend
     }
     
     public Set<String> getUriPrefixes() {
-        return Collections.singleton("soap.tcp");
+        return DEFAULT_PREFIXES;
     }
     public String mapTransportURI(String s, String address) {
         if (SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID.equals(s)
             || (address != null && address.startsWith("jms"))) {
             s = "http://cxf.apache.org/transports/jms";
+        } else if (address != null && address.startsWith("soap.udp")) {
+            s = "http://cxf.apache.org/transports/udp";
         } else if (SOAP_11_HTTP_BINDING.equals(s)
             || SOAP_12_HTTP_BINDING.equals(s)
             || "http://schemas.xmlsoap.org/wsdl/soap/".equals(s)
@@ -127,6 +134,7 @@ public class SoapTransportFactory extend
             if (StringUtils.isEmpty(address) 
                 || address.startsWith("http") 
                 || address.startsWith("jms")
+                || address.startsWith("soap.udp")
                 || address.startsWith("/")) {
                 destinationFactory = mgr.getDestinationFactory(mapTransportURI(transId, address));
             } else {
@@ -217,7 +225,10 @@ public class SoapTransportFactory extend
         ConduitInitiator conduitInit;
         try {
             ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class);
-            if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms"))
{
+            if (StringUtils.isEmpty(address) 
+                || address.startsWith("http")
+                || address.startsWith("jms")
+                || address.startsWith("soap.udp")) {
                 conduitInit = mgr.getConduitInitiator(mapTransportURI(transId, address));
             } else {
                 conduitInit = mgr.getConduitInitiatorForUri(address);

Modified: cxf/trunk/systests/transports/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/pom.xml?rev=1373850&r1=1373849&r2=1373850&view=diff
==============================================================================
--- cxf/trunk/systests/transports/pom.xml (original)
+++ cxf/trunk/systests/transports/pom.xml Thu Aug 16 14:14:16 2012
@@ -113,6 +113,11 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-udp</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
         	<groupId>org.eclipse.jetty</groupId>
         	<artifactId>jetty-servlet</artifactId>
         </dependency>

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/Server.java?rev=1373850&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/Server.java
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/Server.java
Thu Aug 16 14:14:16 2012
@@ -0,0 +1,71 @@
+/**
+ * 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.soap_udp;
+
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.annotations.GZIP;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.hello_world_soap_http.BaseGreeterImpl;
+
+public class Server extends AbstractBusTestServerBase {
+    public static final String PORT = allocatePort(Server.class);
+    
+    Endpoint ep;
+    protected void run() {        
+        Object implementor = new GreeterImpl();
+        String address = "soap.udp://:" + PORT;
+        ep = Endpoint.publish(address, implementor);
+    }
+    @Override
+    public void tearDown() {
+        if (ep != null) {
+            ep.stop();
+        }
+        
+    }
+    
+    
+    public static void main(String[] args) {
+        try {
+            Server s = new Server();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+    
+
+    @WebService(serviceName = "SOAPService",
+                portName = "SoapPort",
+                endpointInterface = "org.apache.hello_world_soap_http.Greeter",
+                targetNamespace = "http://apache.org/hello_world_soap_http",
+                wsdlLocation = "testutils/hello_world.wsdl")
+    @GZIP(threshold = 50)            
+    public class GreeterImpl extends BaseGreeterImpl {
+
+
+    }
+}
+

Added: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/SoapUDPTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/SoapUDPTest.java?rev=1373850&view=auto
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/SoapUDPTest.java
(added)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/soap_udp/SoapUDPTest.java
Thu Aug 16 14:14:16 2012
@@ -0,0 +1,66 @@
+/**
+ * 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.soap_udp;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.hello_world_soap_http.Greeter;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class SoapUDPTest extends AbstractBusClientServerTestBase {
+    private static final String PORT = Server.PORT;
+    private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
+                                            "SOAPService");    
+    private final QName localPortName = new QName("http://apache.org/hello_world_soap_http",
+                                            "UDPPortName");
+    
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        staticBus = BusFactory.getDefaultBus();
+        new LoggingFeature().initialize(staticBus);
+        BusFactory.setThreadDefaultBus(staticBus);
+        assertTrue("server did not launch correctly", launchServer(Server.class, true));
+    }
+    
+    @Test
+    public void testSOAPUDP() {
+        BusFactory.setThreadDefaultBus(staticBus);
+        Service service = Service.create(serviceName);
+        service.addPort(localPortName, "http://schemas.xmlsoap.org/soap/", 
+                        "soap.udp://localhost:" + PORT);
+        Greeter greeter = service.getPort(localPortName, Greeter.class);
+        
+        String reply = greeter.greetMe("test");
+        assertEquals("Hello test", reply);
+        reply = greeter.sayHi();
+        assertNotNull("no response received from service", reply);
+        assertEquals("Bonjour", reply);
+    }
+    
+    
+
+}



Mime
View raw message