cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r454730 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/ rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ tools/common/src/ma...
Date Tue, 10 Oct 2006 13:12:14 GMT
Author: mmao
Date: Tue Oct 10 06:12:13 2006
New Revision: 454730

URL: http://svn.apache.org/viewvc?view=rev&rev=454730
Log:
Generate SOAP12 Message

* SOAPBindingInfo resolve SoapVersion through namespace (bindingId)
* SOAPBinding create SoapVersion based SoapMessage 
* SoapBindingFactory create SoapVersion based SOAPBinding 
* Added unit test with soap12 SoapBindingFactory
* Fixed SOAP12_HTTP_NAMESPACE 
* Should add more unit tests

Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBindingInfo.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapBindingFactoryTest.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java?view=diff&rev=454730&r1=454729&r2=454730
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
Tue Oct 10 06:12:13 2006
@@ -51,6 +51,10 @@
         version = v; 
     }
     
+    public void setSoapVersion(SoapVersion v) {
+        this.version = v;
+    }
+    
     public Message createMessage() {
         return createMessage(new MessageImpl());
     }
@@ -62,7 +66,7 @@
         if (mtomEnabled) {
             m.put(Message.MTOM_ENABLED, Boolean.TRUE);
         }
-        return new SoapMessage(m);
+        return soapMessage;
     }
 
     public List<Interceptor> getFaultInterceptors() {

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=454730&r1=454729&r2=454730
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Tue Oct 10 06:12:13 2006
@@ -116,9 +116,11 @@
         String parameterStyle = SoapConstants.PARAMETER_STYLE_WRAPPED;
         String bindingStyle = SoapConstants.BINDING_STYLE_DOC;
 
-        SoapBinding sb = new SoapBinding();
+        SoapBinding sb = null;
         if (binding instanceof SoapBindingInfo) {
             SoapBindingInfo sbi = (SoapBindingInfo) binding;
+            
+            sb = new SoapBinding(sbi.getSoapVersion());
             // Service wide style
             if (!StringUtils.isEmpty(sbi.getStyle())) {
                 bindingStyle = sbi.getStyle();
@@ -133,6 +135,8 @@
                     parameterStyle = SoapConstants.PARAMETER_STYLE_BARE;
                 }
             }            
+        } else {
+            throw new RuntimeException("Can not initialize SoapBinding, BindingInfo is not
SoapBindingInfo");
         }
 
         sb.getInInterceptors().add(new MultipartMessageInterceptor());
@@ -175,7 +179,7 @@
     public BindingInfo createBindingInfo(ServiceInfo service, javax.wsdl.Binding binding)
{
         String ns = ((ExtensibilityElement) binding.getExtensibilityElements().get(0)).getElementType()
                         .getNamespaceURI();
-        SoapBindingInfo bi = new SoapBindingInfo(service, ns, Soap11.getInstance());
+        SoapBindingInfo bi = new SoapBindingInfo(service, ns);
 
         // Copy all the extensors
         initializeBindingInfo(service, binding, bi);

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBindingInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBindingInfo.java?view=diff&rev=454730&r1=454729&r2=454730
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBindingInfo.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBindingInfo.java
Tue Oct 10 06:12:13 2006
@@ -19,18 +19,27 @@
 
 package org.apache.cxf.binding.soap.model;
 
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 
+import org.apache.cxf.tools.common.WSDLConstants;
+
 public class SoapBindingInfo extends BindingInfo {
     private SoapVersion soapVersion;
 
     private String style;
 
     private String transportURI;
+    
+    public SoapBindingInfo(ServiceInfo serv, String n) {
+        this(serv, n, null);
+        resolveSoapVersion(n);
+    }
 
     public SoapBindingInfo(ServiceInfo serv, String n, SoapVersion soapVersion) {
         super(serv, n);
@@ -38,7 +47,21 @@
         this.soapVersion = soapVersion;
     }
 
+    private void resolveSoapVersion(String n) {
+        if (WSDLConstants.SOAP11_NAMESPACE.equalsIgnoreCase(n)) {
+            this.soapVersion = Soap11.getInstance();
+        } else if (WSDLConstants.SOAP12_NAMESPACE.equalsIgnoreCase(n)) {
+            this.soapVersion = Soap12.getInstance();
+        } else {
+            throw new RuntimeException("Unknow bindingId: " + n + ". Can not resolve the
SOAP version");
+        }
+    }
+
+
     public SoapVersion getSoapVersion() {
+        if (soapVersion == null) {
+            resolveSoapVersion(getBindingId());
+        }
         return soapVersion;
     }
 

Modified: incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapBindingFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapBindingFactoryTest.java?view=diff&rev=454730&r1=454729&r2=454730
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapBindingFactoryTest.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/SoapBindingFactoryTest.java
Tue Oct 10 06:12:13 2006
@@ -31,6 +31,7 @@
 import junit.framework.TestCase;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.binding.BindingFactoryManagerImpl;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
@@ -41,6 +42,7 @@
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.wsdl11.WSDLServiceBuilder;
 import org.easymock.IMocksControl;
@@ -49,16 +51,29 @@
 import static org.easymock.classextension.EasyMock.createNiceControl;
 
 public class SoapBindingFactoryTest extends TestCase {
+    IMocksControl control;
+    
+    public void setUp() {
+        control = createNiceControl();
+    }
+    
+    private Bus getMockBus() {        
+        return control.createMock(Bus.class);        
+    }
+    
+    private BindingFactoryManager getBindingFactoryManager(String ns) throws BusException
{
+        SoapBindingFactory bindingFactory = new SoapBindingFactory();
+        BindingFactoryManager bfm = new BindingFactoryManagerImpl();
+        bfm.registerBindingFactory(ns, bindingFactory);
+        return bfm;
+    }
 
-    public void testFactory() throws Exception {
-        Definition d = createDefinition();
+    public void testFactory() throws Exception {        
+        Definition d = createDefinition("/wsdl/hello_world.wsdl");
 
-        IMocksControl control = createNiceControl();
-        Bus bus = control.createMock(Bus.class);
+        Bus bus = getMockBus();
 
-        SoapBindingFactory bindingFactory = new SoapBindingFactory();
-        BindingFactoryManager bfm = new BindingFactoryManagerImpl();
-        bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
+        BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.SOAP11_NAMESPACE);
 
         expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
         
@@ -77,7 +92,8 @@
 
         SoapBindingInfo sbi = (SoapBindingInfo)bi;
         assertEquals("document", sbi.getStyle());
-        assertEquals("http://schemas.xmlsoap.org/soap/http", sbi.getTransportURI());
+        assertTrue(WSDLConstants.SOAP_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
+        assertTrue(sbi.getSoapVersion() instanceof Soap11);
 
         BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap_http",
                                                               "sayHi"));
@@ -94,10 +110,55 @@
         assertNotNull(parts);
         assertEquals(1, parts.size());
     }
+    
+    
+    public void testSoap12Factory() throws Exception {        
+        Definition d = createDefinition("/wsdl/hello_world_soap12.wsdl");
+
+        Bus bus = getMockBus();
+
+        BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.SOAP12_NAMESPACE);
+
+        expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
+        
+        DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
+        expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
+        
+        control.replay();
+
+        WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
+        ServiceInfo serviceInfo = builder
+            .buildService(d, new QName("http://apache.org/hello_world_soap12_http", "SOAPService"));
+
+        BindingInfo bi = serviceInfo.getBindings().iterator().next();
+
+        assertTrue(bi instanceof SoapBindingInfo);
+
+        SoapBindingInfo sbi = (SoapBindingInfo)bi;
+        assertEquals("document", sbi.getStyle());
+        assertTrue(WSDLConstants.SOAP12_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
+        assertTrue(sbi.getSoapVersion() instanceof Soap12);
+
+        BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http",
+                                                              "sayHi"));
+        SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
+        assertNotNull(sboi);
+        assertEquals("document", sboi.getStyle());
+        assertEquals("", sboi.getAction());
+
+        BindingMessageInfo input = boi.getInput();
+        SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
+        assertEquals("literal", bodyInfo.getUse());
+
+        List<MessagePartInfo> parts = bodyInfo.getParts();
+        assertNotNull(parts);
+        assertEquals(1, parts.size());
+    }
+    
 
-    public Definition createDefinition() throws Exception {
-        URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
-        return WSDLFactory.newInstance().newWSDLReader().readWSDL("hello_world.wsdl",
+    public Definition createDefinition(String wsdlURL) throws Exception {
+        URL resource = getClass().getResource(wsdlURL);
+        return WSDLFactory.newInstance().newWSDLReader().readWSDL(null,
                                                                   new InputSource(resource.openStream()));
     }
 }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java?view=diff&rev=454730&r1=454729&r2=454730
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
Tue Oct 10 06:12:13 2006
@@ -41,7 +41,7 @@
 
     public static final String BINDING = "Binding";
     public static final String SOAP_HTTP_TRANSPORT = "http://schemas.xmlsoap.org/soap/http";
-    public static final String SOAP12_HTTP_TRANSPORT = "http://schemas.xmlsoap.org/soap12/http";
+    public static final String SOAP12_HTTP_TRANSPORT = "http://www.w3.org/2003/05/soap/bindings/http/";
 
     public static final String DOCUMENT = "document";
     public static final String RPC = "rpc";



Mime
View raw message