Author: jason.greene(a)jboss.com
Date: 2007-02-28 18:20:57 -0500 (Wed, 28 Feb 2007)
New Revision: 2485
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
Log:
Fix date/time marshalling
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2007-02-28
12:19:01 UTC (rev 2484)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2007-02-28
23:20:57 UTC (rev 2485)
@@ -30,6 +30,7 @@
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
+import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceException;
import javax.xml.transform.Source;
@@ -70,9 +71,7 @@
Result result = null;
try
{
- // It needs to be a valid JAXB type
- // Therefore we don't need to look into our TypeMapping
- Class javaType = value.getClass();
+ Class javaType = deriveType(value);
JAXBContextCache contextCache = JAXBContextCache.getContextCache();
JAXBContext jaxbContext = contextCache.getInstance(javaType);
@@ -97,6 +96,20 @@
return result;
}
+ private Class deriveType(Object value)
+ {
+ // It needs to be a valid JAXB type
+ // Therefore we don't need to look into our TypeMapping
+ Class javaType = value.getClass();
+
+ // Filter known interface types
+ // Implementation classes will cause JAXB to fail
+ if (XMLGregorianCalendar.class.isAssignableFrom(javaType))
+ javaType = XMLGregorianCalendar.class;
+
+ return javaType;
+ }
+
// 4.21 Conformance (Marshalling failure): If an error occurs when using the supplied
JAXBContext to marshall
// a request or unmarshall a response, an implementation MUST throw a
WebServiceException whose
// cause is set to the original JAXBException.
Show replies by date