cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r529941 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jax...
Date Wed, 18 Apr 2007 09:56:50 GMT
Author: mmao
Date: Wed Apr 18 02:56:49 2007
New Revision: 529941

URL: http://svn.apache.org/viewvc?view=rev&rev=529941
Log:
CXF-539 
 * SoapTransportFactory support soapheader

Added:
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl
Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java?view=diff&rev=529941&r1=529940&r2=529941
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapTransportFactory.java
Wed Apr 18 02:56:49 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.binding.soap;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -35,15 +36,19 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.model.SoapHeaderInfo;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
 import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
 import org.apache.cxf.tools.common.extensions.soap.SoapBody;
+import org.apache.cxf.tools.common.extensions.soap.SoapHeader;
 import org.apache.cxf.tools.common.extensions.soap.SoapOperation;
 import org.apache.cxf.tools.util.SOAPBindingUtil;
 import org.apache.cxf.transport.AbstractTransportFactory;
@@ -80,11 +85,7 @@
 
     public void createPortExtensors(EndpointInfo ei, Service service) {
         SoapBindingInfo bi = (SoapBindingInfo)ei.getBinding();
-        boolean isSoap12 = false;
-        if (bi.getSoapVersion() instanceof Soap12) {
-            isSoap12 = true;
-        }
-        createSoapExtensors(ei, bi, isSoap12);
+        createSoapExtensors(ei, bi, bi.getSoapVersion() instanceof Soap12);
     }
 
     private void createSoapExtensors(EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12)
{
@@ -117,18 +118,58 @@
                 b.addExtensor(soapOperation);
 
                 if (b.getInput() != null) {
+                    List<String> bodyParts = new ArrayList<String>();
+                    SoapHeaderInfo headerInfo = b.getInput().getExtensor(SoapHeaderInfo.class);
+                    if (headerInfo != null) {
+                        SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry,
+                                                                                 BindingInput.class,
+                                                                                 isSoap12);
+                        soapHeader.setMessage(b.getInput().getMessageInfo().getName());
+                        soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
+                        soapHeader.setUse("literal");
+                        b.getInput().addExtensor(soapHeader);
+
+                        for (MessagePartInfo part : b.getInput().getMessageParts()) {
+                            bodyParts.add(part.getName().getLocalPart());
+                        }
+                    } 
                     SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry,
                                                                    BindingInput.class,
                                                                    isSoap12);
                     body.setUse("literal");
+
+                    if (!StringUtils.isEmpty(bodyParts)) {
+                        body.setParts(bodyParts);
+                    }
+
                     b.getInput().addExtensor(body);
                 }
 
                 if (b.getOutput() != null) {
+                    List<String> bodyParts = new ArrayList<String>();
+                    SoapHeaderInfo headerInfo = b.getOutput().getExtensor(SoapHeaderInfo.class);
+                    if (headerInfo != null) {
+                        SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry,
+                                                                                 BindingOutput.class,
+                                                                                 isSoap12);
+                        soapHeader.setMessage(b.getOutput().getMessageInfo().getName());
+                        soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
+                        soapHeader.setUse("literal");
+                        b.getOutput().addExtensor(soapHeader);
+
+                        for (MessagePartInfo part : b.getOutput().getMessageParts()) {
+                            bodyParts.add(part.getName().getLocalPart());
+                        }
+                    }
                     SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry,
                                                                    BindingOutput.class,
                                                                    isSoap12);
                     body.setUse("literal");
+
+                    if (!StringUtils.isEmpty(bodyParts)) {
+                        body.setParts(bodyParts);
+                    }
+                    
                     b.getOutput().addExtensor(body);
                 }
             }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=529941&r1=529940&r2=529941
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Wed Apr 18 02:56:49 2007
@@ -438,7 +438,6 @@
 
     protected void createMessageParts(InterfaceInfo intf, OperationInfo op, Method method)
{
         final Class[] paramClasses = method.getParameterTypes();
-
         // Setup the input message
         MessageInfo inMsg = op.createMessage(this.getInputMessageName(op, method));     
  
         op.setInput(inMsg.getName().getLocalPart(), inMsg);
@@ -484,7 +483,7 @@
                     }
                     final QName q = getOutPartName(op, method, j);
                     final QName q2 = getOutParameterName(op, method, j);
-                    MessagePartInfo part = outMsg.addMessagePart(q);               
+                    MessagePartInfo part = outMsg.addMessagePart(q);
                     if (!isRPC(method) && !isWrapped(method) && wrappedStyle
== null) {
                         part.setElementQName(q2);
                     } 

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?view=diff&rev=529941&r1=529940&r2=529941
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Wed Apr 18 02:56:49 2007
@@ -43,6 +43,11 @@
         builder.setBus(BusFactory.getDefaultBus());
     }
 
+    @org.junit.After
+    public void tearDown() {
+        super.tearDown();
+    }
+
 
     @Test
     public void testGetOutputFile() {
@@ -222,9 +227,8 @@
         assertTrue(output.exists());
     }
 
-    // TODO:
+    // PASSED
     @Test
-    @Ignore
     public void testSoapHeader() throws Exception {
 
         builder.setServiceClass(org.apache.samples.headers.HeaderTester.class);
@@ -232,10 +236,12 @@
 
         generator.setServiceModel(service);
         File file = getOutputFile("soap_header.wsdl");
-        assertNotNull(output);
+        assertNotNull(file);
         generator.generate(file);
-        assertTrue(output.exists());
+        assertTrue(file.exists());
 
+        String expectedFile = this.getClass().getResource("expected/soap_header.wsdl").getFile();
+        assertFileEquals(new File(expectedFile), file);
     }
 
     // TODO:
@@ -257,5 +263,4 @@
     private File getOutputFile(String fileName) {
         return new File(output, fileName);
     }
-
 }

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl?view=auto&rev=529941
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/expected/soap_header.wsdl
Wed Apr 18 02:56:49 2007
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="HeaderTesterService" targetNamespace="http://apache.org/samples/headers"
xmlns:ns1="http://apache.org/samples/headers" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <wsdl:types>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://apache.org/samples/headers"
targetNamespace="http://apache.org/samples/headers" version="1.0">
+<xs:element name="SOAPHeaderInfo" nillable="true" type="tns:SOAPHeaderData"/>
+<xs:element name="inHeader">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="requestType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="inHeaderResponse">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="responseType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="inoutHeader">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="requestType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="inoutHeaderResponse">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="responseType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="outHeader">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="requestType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:element name="outHeaderResponse">
+<xs:complexType>
+<xs:sequence>
+<xs:element name="responseType" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:element>
+<xs:complexType name="SOAPHeaderData">
+<xs:sequence>
+<xs:element name="originator" type="xs:string"/>
+<xs:element name="message" type="xs:string"/>
+</xs:sequence>
+</xs:complexType>
+</xs:schema>
+  </wsdl:types>
+  <wsdl:message name="inHeaderResponse">
+    <wsdl:part name="the_response" element="ns1:inHeaderResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="outHeader">
+    <wsdl:part name="me" element="ns1:outHeader">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="outHeaderResponse">
+    <wsdl:part name="the_response" element="ns1:outHeaderResponse">
+    </wsdl:part>
+    <wsdl:part name="header_info" element="ns1:SOAPHeaderInfo">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="inoutHeader">
+    <wsdl:part name="me" element="ns1:inoutHeader">
+    </wsdl:part>
+    <wsdl:part name="header_info" element="ns1:SOAPHeaderInfo">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="inoutHeaderResponse">
+    <wsdl:part name="the_response" element="ns1:inoutHeaderResponse">
+    </wsdl:part>
+    <wsdl:part name="header_info" element="ns1:SOAPHeaderInfo">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="inHeader">
+    <wsdl:part name="me" element="ns1:inHeader">
+    </wsdl:part>
+    <wsdl:part name="header_info" element="ns1:SOAPHeaderInfo">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="headerTester">
+    <wsdl:operation name="outHeader">
+      <wsdl:input name="outHeader" message="ns1:outHeader">
+    </wsdl:input>
+      <wsdl:output name="outHeaderResponse" message="ns1:outHeaderResponse">
+    </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="inHeader">
+      <wsdl:input name="inHeader" message="ns1:inHeader">
+    </wsdl:input>
+      <wsdl:output name="inHeaderResponse" message="ns1:inHeaderResponse">
+    </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="inoutHeader">
+      <wsdl:input name="inoutHeader" message="ns1:inoutHeader">
+    </wsdl:input>
+      <wsdl:output name="inoutHeaderResponse" message="ns1:inoutHeaderResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="HeaderTesterServiceSoapBinding" type="ns1:headerTester">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="outHeader">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="outHeader">
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="outHeaderResponse">
+        <soap:header message="ns1:outHeaderResponse" part="header_info" use="literal">
+        </soap:header>
+        <soap:body parts="the_response" use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="inHeader">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="inHeader">
+        <soap:header message="ns1:inHeader" part="header_info" use="literal">
+        </soap:header>
+        <soap:body parts="me" use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="inHeaderResponse">
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="inoutHeader">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="inoutHeader">
+        <soap:header message="ns1:inoutHeader" part="header_info" use="literal">
+        </soap:header>
+        <soap:body parts="me" use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="inoutHeaderResponse">
+        <soap:header message="ns1:inoutHeaderResponse" part="header_info" use="literal">
+        </soap:header>
+        <soap:body parts="the_response" use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="HeaderTesterService">
+    <wsdl:port name="HeaderTesterPort" binding="ns1:HeaderTesterServiceSoapBinding">
+      <soap:address location="http://localhost:9090"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>



Mime
View raw message