You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by suiaing <su...@gmail.com> on 2007/08/17 06:31:00 UTC

DataBinding problems (Timestamp and HashMap) using JAXB

Does the JAXB using in the CXF 2.0.1 support the java.sql.Timestamp and
java.util.HashMap?:-(

i have a web method like this:
public void echo(java.util.Date date, java.sql.Timestamp timestamp);
Howerver, i find this message defination in the wsdl which is generated by
cxf
 <wsdl:message name="echo">
    <wsdl:part name="arg0" type="xsd:dateTime">
    </wsdl:part>
    <wsdl:part name="arg1">
    </wsdl:part>
  </wsdl:message>

I also have a web method like this
public void echo2(HashMap<String, String> map);
Howerver, i find these in the wsdl which is generated by cxf:
<xs:complexType name="hashMap">
<xs:complexContent>
<xs:extension base="abstractMap">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType abstract="true" name="abstractMap"/>

<wsdl:message name="echo2">
    <wsdl:part name="arg0" type="ns1:hashMap">
    </wsdl:part>
  </wsdl:message>

how can i use java.util.Map datatype with JAXB in CXF ?
-- 
View this message in context: http://www.nabble.com/DataBinding-problems-%28Timestamp-and-HashMap%29-using-JAXB-tf4283645.html#a12193877
Sent from the cxf-user mailing list archive at Nabble.com.


RE: DataBinding problems (Timestamp and HashMap) using JAXB

Posted by "Liu, Jervis" <jl...@iona.com>.
Neither java.sql.Timestamp nor HashMap are supported by JAXB. A common practice is abstracting data from unsupported types to a supported JAVA types or to user defined POJOs. For example, Timestamp can be represented as a String, and if you know HashMap is used as HashMap<Integer, String>, you can write a class like below:

     public class MyHashMapType {
         List<MyHashMapEntryType> entry;
     }

     public class MyHashMapEntryType {
         @XmlAttribute
         public Integer key; 

         @XmlValue
         public String value;
     }

> -----Original Message-----
> From: suiaing [mailto:suiaing@gmail.com]
> Sent: 2007?8?17? 12:31
> To: cxf-user@incubator.apache.org
> Subject: DataBinding problems (Timestamp and HashMap) using JAXB
> 
> 
> 
> Does the JAXB using in the CXF 2.0.1 support the 
> java.sql.Timestamp and
> java.util.HashMap?:-(
> 
> i have a web method like this:
> public void echo(java.util.Date date, java.sql.Timestamp timestamp);
> Howerver, i find this message defination in the wsdl which is 
> generated by
> cxf
>  <wsdl:message name="echo">
>     <wsdl:part name="arg0" type="xsd:dateTime">
>     </wsdl:part>
>     <wsdl:part name="arg1">
>     </wsdl:part>
>   </wsdl:message>
> 
> I also have a web method like this
> public void echo2(HashMap<String, String> map);
> Howerver, i find these in the wsdl which is generated by cxf:
> <xs:complexType name="hashMap">
> <xs:complexContent>
> <xs:extension base="abstractMap">
> <xs:sequence/>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
> <xs:complexType abstract="true" name="abstractMap"/>
> 
> <wsdl:message name="echo2">
>     <wsdl:part name="arg0" type="ns1:hashMap">
>     </wsdl:part>
>   </wsdl:message>
> 
> how can i use java.util.Map datatype with JAXB in CXF ?
> -- 
> View this message in context: 
> http://www.nabble.com/DataBinding-problems-%28Timestamp-and-Ha
shMap%29-using-JAXB-tf4283645.html#a12193877
Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland