cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r576586 - in /incubator/cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/ systests/src/test/java/org/apache/cxf/systest/basicDOCBare/ systests/src/test/java/org/apach...
Date Mon, 17 Sep 2007 21:06:35 GMT
Author: dkulp
Date: Mon Sep 17 14:06:33 2007
New Revision: 576586

URL: http://svn.apache.org/viewvc?rev=576586&view=rev
Log:
[CXF-970] Patch from Jeff Yu applied.

Modified:
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/DOCBareClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/PutLastTradedPriceImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/DocLitBareImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/doc_lit_bare.wsdl

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Mon Sep 17 14:06:33 2007
@@ -200,6 +200,27 @@
     public static void marshall(JAXBContext context, Schema schema, Object elValue, Object
source) {
         marshall(context, schema, elValue, null, source, null);
     }
+    
+    @SuppressWarnings("unchecked")
+    public static void marshallNullElement(JAXBContext context, Schema schema, 
+                                               Object source, MessagePartInfo part) {
+        Class<?> clazz = part != null ? (Class) part.getTypeClass() : null;
+        try {
+            Marshaller u = createMarshaller(context, clazz);
+            u.setSchema(schema);
+            try {
+                // The Marshaller.JAXB_FRAGMENT will tell the Marshaller not to
+                // generate the xml declaration.
+                u.setProperty(Marshaller.JAXB_FRAGMENT, true);
+                u.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
+            } catch (javax.xml.bind.PropertyException e) {
+                // intentionally empty.
+            }
+            writeObject(u, source, new JAXBElement(part.getElementQName(), clazz, null));
+        } catch (JAXBException e) {
+            throw new Fault(new Message("MARSHAL_ERROR", BUNDLE, e.getMessage()), e);
+        } 
+    }
 
     public static void marshall(JAXBContext context, Schema schema, 
                                 Object elValue, 

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
Mon Sep 17 14:06:33 2007
@@ -41,6 +41,16 @@
             || !(part.getXmlSchema() instanceof XmlSchemaElement)) {
             JAXBEncoderDecoder.marshall(getJAXBContext(), getSchema(), obj, part, output,

                                         getAttachmentMarrshaller());
+        } else if (obj == null && needToRender(obj, part)) {
+            JAXBEncoderDecoder.marshallNullElement(getJAXBContext(), getSchema(), output,
part);
         }
+    }
+
+    private boolean needToRender(Object obj, MessagePartInfo part) {
+        if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) {
+            XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema();
+            return element.isNillable() && element.getMinOccurs() > 0;
+        }
+        return false;
     }
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/DOCBareClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/DOCBareClientServerTest.java?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/DOCBareClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/DOCBareClientServerTest.java
Mon Sep 17 14:06:33 2007
@@ -98,6 +98,20 @@
             }
         }
     }
+    
+    @Test
+    public void testNillableParameter() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/doc_lit_bare.wsdl");
+        assertNotNull("WSDL is null", wsdl);
+
+        SOAPService service = new SOAPService(wsdl, serviceName);
+        assertNotNull("Service is null", service);
+
+        PutLastTradedPricePortType port = service.getPort(portName,
+                                                          PutLastTradedPricePortType.class);
+        String result = port.nillableParameter(null);
+        assertNull(result);
+    } 
 
 
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/PutLastTradedPriceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/PutLastTradedPriceImpl.java?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/PutLastTradedPriceImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/basicDOCBare/PutLastTradedPriceImpl.java
Mon Sep 17 14:06:33 2007
@@ -18,6 +18,8 @@
  */
 
 package org.apache.cxf.systest.basicDOCBare;
+import java.math.BigDecimal;
+
 import javax.xml.ws.Holder;
 
 import org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType;
@@ -43,6 +45,9 @@
     
     public String bareNoParam() {
         return "testResponse";
+    }
+    public String nillableParameter(BigDecimal theRequest) {
+        return null;
     }
    
 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHdrServiceImpl.java
Mon Sep 17 14:06:33 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.outofband.header;
 
+import java.math.BigDecimal;
 import java.util.Iterator;
 import java.util.List;
 
@@ -30,6 +31,7 @@
 import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
+
 import org.w3c.dom.Node;
 
 import org.apache.cxf.headers.Header;
@@ -42,6 +44,7 @@
 
 
 
+
 @javax.jws.WebService(serviceName = "SOAPService", 
                       portName = "SoapPort",
                       endpointInterface = "org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType",
@@ -140,6 +143,10 @@
     
     public String bareNoParam() {
         return "testResponse";
+    }
+
+    public String nillableParameter(BigDecimal theRequest) {
+        return null;
     }
    
 

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/DocLitBareImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/DocLitBareImpl.java?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/DocLitBareImpl.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/DocLitBareImpl.java
Mon Sep 17 14:06:33 2007
@@ -19,6 +19,8 @@
 
 package org.apache.hello_world_soap_http;
 
+import java.math.BigDecimal;
+
 import javax.jws.WebService;
 import javax.xml.ws.Holder;
 import org.apache.hello_world_doc_lit_bare.PutLastTradedPricePortType;
@@ -55,5 +57,9 @@
     
     public int getBareNoParamCount() {
         return bareNoParamCallCount;
+    }
+
+    public String nillableParameter(BigDecimal theRequest) {
+        return null;
     }
 }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/doc_lit_bare.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/doc_lit_bare.wsdl?rev=576586&r1=576585&r2=576586&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/doc_lit_bare.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/doc_lit_bare.wsdl Mon Sep 17 14:06:33
2007
@@ -29,6 +29,8 @@
             <element name="in" type="tns:TradePriceData"/>
             <element name="inout" type="tns:TradePriceData"/>
             <element name="stringRespType" type="xsd:string"/>
+            <element name="inDecimal" nillable="true" type="xsd:decimal" />
+            <element name="outString" nillable="true" type="xsd:string" />
         </schema>
     </wsdl:types>
     <message name="PutLastTradedPriceInput">
@@ -48,6 +50,14 @@
     <message name="bareNoParamResponse">
         <part element="x1:stringRespType" name="theResponse"/>
     </message>
+    
+    <message name="nillableRequest">
+    	<part name="theRequest" element="x1:inDecimal" />
+    </message>
+    
+    <message name="nillableResponse">
+    	<part name="theResponse" element="x1:outString" />
+    </message>
 
     <portType name="PutLastTradedPricePortType">
 
@@ -66,6 +76,11 @@
             <output message="tns:bareNoParamResponse"/>
         </operation>
         
+        <operation name="nillableParameter">
+        	<input message="tns:nillableRequest" />
+        	<output message="tns:nillableResponse" />
+        </operation>
+        
     </portType>
     
     <binding name="PutLastTradedPriceSoapBinding" type="tns:PutLastTradedPricePortType">
@@ -96,7 +111,17 @@
             <output>
                 <soap:body use="literal"/>
             </output>
-        </operation>        
+        </operation>
+        
+        <operation name="nillableParameter">
+        	<input>
+        		<soap:body use="literal" />
+        	</input>
+        	<output>
+        		<soap:body use="literal" />
+        	</output>        
+        </operation>
+                
     </binding>
     <wsdl:service name="SOAPService">
         <wsdl:port name="SoapPort" binding="tns:PutLastTradedPriceSoapBinding">



Mime
View raw message