You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Cord Awtry <ki...@gmail.com> on 2008/05/19 20:49:29 UTC

dateTime custom binding

Hello all,

  Wondering if someone can lend some advice on an issue I'm seeing (may not
even be an issue, I'm open to that as an answer ;) ). Essentially, I have a
WSDL being generated by CXF with all my types inline. I have a bunch of
xs:datetime objects which are being converted to XMLGregorianCalendar when I
run wsdlToJava. I've done a bunch of research on this, seen several
solutions and have yet to see anything work. I've copied the code from the
cwiki for solving this, but still no resolution. It's possible what I view
as the proper resolution may be incorrect. Essentially, I'd like to get rid
of all the instances of XMLGregorianCalendar in my generated java files and
have them be java.util.Date objects. Below is a copy of my bindings that I'm
using with CXF 2.1. If anyone has any thoughts as to why I'm still getting
XMLGregorianCalendar objects in my generated java files, I'd be more than
happy to hear it.

  Thanks,

    -C-

<jaxws:bindings wsdlLocation="
http://127.0.0.1:8080/ext/services/Extension?wsdl"
                xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
http://www.tmu.com/services/Extension/2008/05']">
    <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"

 parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"

 printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
    </jxb:globalBindings>
  </jaxws:bindings>
</jaxws:bindings>

Re: dateTime custom binding [Virus checked]

Posted by Daniel Kulp <dk...@apache.org>.
On May 20, 2008, at 3:26 PM, Cord Awtry wrote:

> Thanks Dan, that's kind of what I thought.
>
> So, the question is, if I override dateTime to be Calendar instead of
> XMLGregorianCalendar, could that cause problems with those asm  
> generated
> classes?

Possibly.   I'm not really sure though.  :-(

I've honestly never tried using the Date/Calendar type converter  
things so I'm not exactly sure what they do.

> I'm trying to create a small test service which'll expose the  
> problem. While
> debugging, I did see both the Calendar and XMLGregorianCalendar  
> objects
> present, but I don't have enough context to know if they really  
> should both
> be there.

If you can get a test case that shows the problem, that would be  
great.   I can dig into the asm code to figure out what it's supposed  
to be doing.

One more option: in many cases, (almost all of the wsdl first cases)  
you can remove the asm.jar from the classpath and it will revert to  
the slower reflection based methods.   Thus, that may work if the bug  
is in the asm versions.

Dan



>
>
> Thanks,
>
>  -C-
>
> On Tue, May 20, 2008 at 2:28 PM, Daniel Kulp <dk...@apache.org> wrote:
>
>>
>> On May 20, 2008, at 1:22 PM, Cord Awtry wrote:
>>
>> Hmmm. I'm fairly certain I have it set up right. And those
>>> WrapperTypeHelper
>>> classes are no-where to be found on my system. Do they get created  
>>> on the
>>> fly by cxf during the processing?
>>>
>>
>> Yes, they do. We use asm to generate some helper classes to pull data
>> in/out of the wrapper classes to deal with the unwrapping.   It's  
>> quite a
>> bit faster than using reflection to do that all the time.
>>
>> Dan
>>
>>
>>
>>
>>>
>>> On Tue, May 20, 2008 at 8:24 AM, <jan.minaroviech@external.t-mobile.at 
>>> >
>>> wrote:
>>>
>>> Hello,
>>>>
>>>> well, according to my sources, it'll return  
>>>> java.util.GregorianCalendar
>>>> (but internally during it's creation also XMLGregorianCalendar is  
>>>> used)
>>>>
>>>> didn't you mixed something?
>>>> after i used CalendarAdapter (instead of setting parse/print  
>>>> methods),
>>>> alll strange classes like
>>>> foo.bar.SetOrderCalendarDates_WrapperTypeHelper1
>>>> has disappeared from my project.
>>>>
>>>> best regards
>>>> jano
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> "Cord Awtry" <ki...@gmail.com>
>>>> 05/20/2008 14:01
>>>> Bitte antworten an
>>>> users@cxf.apache.org
>>>>
>>>>
>>>> An
>>>> users@cxf.apache.org
>>>> Kopie
>>>>
>>>> Thema
>>>> Re: dateTime custom binding [Virus checked]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Jano,
>>>>
>>>> That did the trick, thanks. I'm curious if you or anyone else has  
>>>> any
>>>> insight on a follow-up question. It would seem the  
>>>> XMLGregorianCalendar
>>>> is
>>>> still in use, at least partially, after using the custom bindings  
>>>> file to
>>>> convert them all to java.util.Calendar objects. Below is a
>>>> ClassCastException with an XMLGregorianCalendar as well as code  
>>>> snippets
>>>> from the source.
>>>>
>>>> Thanks again,
>>>>
>>>> -C-
>>>>
>>>> ***EXCEPTION***
>>>> Caused by: java.lang.ClassCastException:
>>>> com 
>>>> .sun 
>>>> .org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
>>>>     at
>>>>
>>>>
>>>> foo 
>>>> .bar 
>>>> .SetOrderCalendarDates_WrapperTypeHelper1 
>>>> .createWrapperObject(Unknown
>>>> Source)
>>>>     at
>>>>
>>>>
>>>> org 
>>>> .apache 
>>>> .cxf 
>>>> .jaxws 
>>>> .interceptors 
>>>> .WrapperClassOutInterceptor 
>>>> .handleMessage(WrapperClassOutInterceptor.java:102)
>>>>     ... 49 more
>>>>
>>>> ***JAVA OBJECT FOR WS CALL***
>>>> /**
>>>> * <p>Java class for anonymous complex type.
>>>> *
>>>> * <p>The following schema fragment specifies the expected content
>>>> contained
>>>> within this class.
>>>> *
>>>> * <pre>
>>>> * &lt;complexType>
>>>> *   &lt;complexContent>
>>>> *     &lt;restriction base="{http://www.w3.org/2001/ 
>>>> XMLSchema}anyType<
>>>> http://www.w3.org/2001/XMLSchema%7DanyType>
>>>> ">
>>>> *       &lt;sequence>
>>>> *         &lt;element name="requiredDates"
>>>> type="{http://bar.foo}ArrayOfDateTime"
>>>> minOccurs="0"/>
>>>> *       &lt;/sequence>
>>>> *     &lt;/restriction>
>>>> *   &lt;/complexContent>
>>>> * &lt;/complexType>
>>>> * </pre>
>>>> *
>>>> *
>>>> */
>>>> @XmlAccessorType(XmlAccessType.FIELD)
>>>> @XmlType(name = "", propOrder = {
>>>> "requiredDates",
>>>> })
>>>> @XmlRootElement(name = "SetOrderCalendarDates")
>>>> public class SetOrderCalendarDates {
>>>> protected ArrayOfDateTime requiredDates;
>>>> .
>>>> .
>>>> .
>>>> }
>>>>
>>>> ***CHILD OBJECT***
>>>> /**
>>>> * <p>Java class for ArrayOfDateTime complex type.
>>>> *
>>>> * <p>The following schema fragment specifies the expected content
>>>> contained
>>>> within this class.
>>>> *
>>>> * <pre>
>>>> * &lt;complexType name="ArrayOfDateTime">
>>>> *   &lt;complexContent>
>>>> *     &lt;restriction base="{http://www.w3.org/2001/ 
>>>> XMLSchema}anyType<
>>>> http://www.w3.org/2001/XMLSchema%7DanyType>
>>>> ">
>>>> *       &lt;sequence>
>>>> *         &lt;element name="dateTime" type="{
>>>> http://www.w3.org/2001/XMLSchema}dateTime<http://www.w3.org/2001/XMLSchema%7DdateTime 
>>>> >
>>>> <http://www.w3.org/2001/XMLSchema%7DdateTime>"
>>>>
>>>> maxOccurs="unbounded"
>>>> minOccurs="0"/>
>>>> *       &lt;/sequence>
>>>> *     &lt;/restriction>
>>>> *   &lt;/complexContent>
>>>> * &lt;/complexType>
>>>> * </pre>
>>>> *
>>>> *
>>>> */
>>>> @XmlAccessorType(XmlAccessType.FIELD)
>>>> @XmlType(name = "ArrayOfDateTime", propOrder = {
>>>> "dateTime"
>>>> })
>>>> public class ArrayOfDateTime {
>>>>
>>>> @XmlElement(type = String.class)
>>>> @XmlJavaTypeAdapter(CalendarXMLAdapter.class)
>>>> @XmlSchemaType(name = "dateTime")
>>>> protected List<Calendar> dateTime;
>>>>
>>>> public List<Calendar> getDateTime() {
>>>>     if (dateTime == null) {
>>>>         dateTime = new ArrayList<Calendar>();
>>>>     }
>>>>     return this.dateTime;
>>>> }
>>>>
>>>> }
>>>>
>>>> On Mon, May 19, 2008 at 2:56 PM, <jan.minaroviech@external.t-mobile.at 
>>>> >
>>>> wrote:
>>>>
>>>> Hello,
>>>>>
>>>>> see below.
>>>>>
>>>>> best regards
>>>>> jano
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <bindings version="2.1"
>>>>>     xmlns="http://java.sun.com/xml/ns/jaxb"
>>>>>     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>>>>     xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>>>>>
>>>>>>
>>>>>>
>>>>>     <globalBindings>
>>>>>             <xjc:javaType name="java.util.Calendar"
>>>>>
>>>> xmlType="xsd:date"
>>>>
>>>>>                     adapter="xxx.common.jaxb.CalendarAdapter" />
>>>>>
>>>>>             <xjc:javaType name="java.util.Calendar"
>>>>>
>>>> xmlType="xsd:time"
>>>>
>>>>>                     adapter="xxx.common.jaxb.CalendarAdapter" />
>>>>>
>>>>>             <xjc:javaType name="java.util.Calendar"
>>>>> xmlType="xsd:dateTime"
>>>>>                     adapter="xxx.common.jaxb.CalendarAdapter" />
>>>>>     </globalBindings>
>>>>> </bindings>
>>>>>
>>>>>
>>>>> package xxx.common.jaxb;
>>>>>
>>>>> import java.util.Calendar;
>>>>>
>>>>> import javax.xml.bind.annotation.adapters.XmlAdapter;
>>>>>
>>>>> public class CalendarAdapter extends XmlAdapter<String,  
>>>>> Calendar> {
>>>>>
>>>>>     public Calendar unmarshal(String value) {
>>>>>     return  
>>>>> (javax.xml.bind.DatatypeConverter.parseDateTime(value));
>>>>> }
>>>>>
>>>>> public String marshal(Calendar value) {
>>>>>     if (value == null) {
>>>>>         return null;
>>>>>     }
>>>>>     return  
>>>>> (javax.xml.bind.DatatypeConverter.printDateTime(value));
>>>>> }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "Cord Awtry" <ki...@gmail.com>
>>>>> 05/19/2008 20:49
>>>>> Bitte antworten an
>>>>> users@cxf.apache.org
>>>>>
>>>>>
>>>>> An
>>>>> users@cxf.apache.org
>>>>> Kopie
>>>>>
>>>>> Thema
>>>>> dateTime custom binding  [Virus checked]
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Hello all,
>>>>>
>>>>> Wondering if someone can lend some advice on an issue I'm seeing  
>>>>> (may
>>>>> not
>>>>> even be an issue, I'm open to that as an answer ;) ).  
>>>>> Essentially, I
>>>>>
>>>> have
>>>>
>>>>> a
>>>>> WSDL being generated by CXF with all my types inline. I have a  
>>>>> bunch of
>>>>> xs:datetime objects which are being converted to  
>>>>> XMLGregorianCalendar
>>>>>
>>>> when
>>>>
>>>>> I
>>>>> run wsdlToJava. I've done a bunch of research on this, seen  
>>>>> several
>>>>> solutions and have yet to see anything work. I've copied the  
>>>>> code from
>>>>>
>>>> the
>>>>
>>>>> cwiki for solving this, but still no resolution. It's possible  
>>>>> what I
>>>>>
>>>> view
>>>>
>>>>> as the proper resolution may be incorrect. Essentially, I'd like  
>>>>> to get
>>>>> rid
>>>>> of all the instances of XMLGregorianCalendar in my generated  
>>>>> java files
>>>>> and
>>>>> have them be java.util.Date objects. Below is a copy of my  
>>>>> bindings that
>>>>> I'm
>>>>> using with CXF 2.1. If anyone has any thoughts as to why I'm still
>>>>>
>>>> getting
>>>>
>>>>> XMLGregorianCalendar objects in my generated java files, I'd be  
>>>>> more
>>>>>
>>>> than
>>>>
>>>>> happy to hear it.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> -C-
>>>>>
>>>>> <jaxws:bindings wsdlLocation="
>>>>> http://127.0.0.1:8080/ext/services/Extension?wsdl"
>>>>>             xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>>>>>             xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>>>             xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>>>>             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>>>>> <jaxws:bindings
>>>>> node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
>>>>> http://www.tmu.com/services/Extension/2008/05'<
>>>>>
>>>> http://www.tmu.com/services/Extension/2008/05%27>
>>>>
>>>>> ]">
>>>>> <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>>>> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>>>>>   <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
>>>>>
>>>>> parseMethod 
>>>>> ="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
>>>>>
>>>>>
>>>>> printMethod 
>>>>> ="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
>>>>
>>>>> </jxb:globalBindings>
>>>>> </jaxws:bindings>
>>>>> </jaxws:bindings>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>> ---
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>>
>>
>>
>>
>>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog





Re: dateTime custom binding [Virus checked]

Posted by Cord Awtry <ki...@gmail.com>.
Thanks Dan, that's kind of what I thought.

So, the question is, if I override dateTime to be Calendar instead of
XMLGregorianCalendar, could that cause problems with those asm generated
classes?

I'm trying to create a small test service which'll expose the problem. While
debugging, I did see both the Calendar and XMLGregorianCalendar objects
present, but I don't have enough context to know if they really should both
be there.

Thanks,

  -C-

On Tue, May 20, 2008 at 2:28 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> On May 20, 2008, at 1:22 PM, Cord Awtry wrote:
>
>  Hmmm. I'm fairly certain I have it set up right. And those
>> WrapperTypeHelper
>> classes are no-where to be found on my system. Do they get created on the
>> fly by cxf during the processing?
>>
>
> Yes, they do. We use asm to generate some helper classes to pull data
> in/out of the wrapper classes to deal with the unwrapping.   It's quite a
> bit faster than using reflection to do that all the time.
>
> Dan
>
>
>
>
>>
>> On Tue, May 20, 2008 at 8:24 AM, <ja...@external.t-mobile.at>
>> wrote:
>>
>>  Hello,
>>>
>>> well, according to my sources, it'll return java.util.GregorianCalendar
>>> (but internally during it's creation also XMLGregorianCalendar is used)
>>>
>>> didn't you mixed something?
>>> after i used CalendarAdapter (instead of setting parse/print methods),
>>> alll strange classes like
>>> foo.bar.SetOrderCalendarDates_WrapperTypeHelper1
>>> has disappeared from my project.
>>>
>>> best regards
>>> jano
>>>
>>>
>>>
>>>
>>>
>>>
>>> "Cord Awtry" <ki...@gmail.com>
>>> 05/20/2008 14:01
>>> Bitte antworten an
>>> users@cxf.apache.org
>>>
>>>
>>> An
>>> users@cxf.apache.org
>>> Kopie
>>>
>>> Thema
>>> Re: dateTime custom binding [Virus checked]
>>>
>>>
>>>
>>>
>>>
>>>
>>> Jano,
>>>
>>> That did the trick, thanks. I'm curious if you or anyone else has any
>>> insight on a follow-up question. It would seem the XMLGregorianCalendar
>>> is
>>> still in use, at least partially, after using the custom bindings file to
>>> convert them all to java.util.Calendar objects. Below is a
>>> ClassCastException with an XMLGregorianCalendar as well as code snippets
>>> from the source.
>>>
>>> Thanks again,
>>>
>>>  -C-
>>>
>>> ***EXCEPTION***
>>> Caused by: java.lang.ClassCastException:
>>> com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
>>>      at
>>>
>>>
>>> foo.bar.SetOrderCalendarDates_WrapperTypeHelper1.createWrapperObject(Unknown
>>> Source)
>>>      at
>>>
>>>
>>> org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:102)
>>>      ... 49 more
>>>
>>> ***JAVA OBJECT FOR WS CALL***
>>> /**
>>> * <p>Java class for anonymous complex type.
>>> *
>>> * <p>The following schema fragment specifies the expected content
>>> contained
>>> within this class.
>>> *
>>> * <pre>
>>> * &lt;complexType>
>>> *   &lt;complexContent>
>>> *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType<
>>> http://www.w3.org/2001/XMLSchema%7DanyType>
>>> ">
>>> *       &lt;sequence>
>>> *         &lt;element name="requiredDates"
>>> type="{http://bar.foo}ArrayOfDateTime"
>>> minOccurs="0"/>
>>> *       &lt;/sequence>
>>> *     &lt;/restriction>
>>> *   &lt;/complexContent>
>>> * &lt;/complexType>
>>> * </pre>
>>> *
>>> *
>>> */
>>> @XmlAccessorType(XmlAccessType.FIELD)
>>> @XmlType(name = "", propOrder = {
>>>  "requiredDates",
>>> })
>>> @XmlRootElement(name = "SetOrderCalendarDates")
>>> public class SetOrderCalendarDates {
>>>  protected ArrayOfDateTime requiredDates;
>>> .
>>> .
>>> .
>>> }
>>>
>>> ***CHILD OBJECT***
>>> /**
>>> * <p>Java class for ArrayOfDateTime complex type.
>>> *
>>> * <p>The following schema fragment specifies the expected content
>>> contained
>>> within this class.
>>> *
>>> * <pre>
>>> * &lt;complexType name="ArrayOfDateTime">
>>> *   &lt;complexContent>
>>> *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType<
>>> http://www.w3.org/2001/XMLSchema%7DanyType>
>>> ">
>>> *       &lt;sequence>
>>> *         &lt;element name="dateTime" type="{
>>> http://www.w3.org/2001/XMLSchema}dateTime<http://www.w3.org/2001/XMLSchema%7DdateTime>
>>> <http://www.w3.org/2001/XMLSchema%7DdateTime>"
>>>
>>> maxOccurs="unbounded"
>>> minOccurs="0"/>
>>> *       &lt;/sequence>
>>> *     &lt;/restriction>
>>> *   &lt;/complexContent>
>>> * &lt;/complexType>
>>> * </pre>
>>> *
>>> *
>>> */
>>> @XmlAccessorType(XmlAccessType.FIELD)
>>> @XmlType(name = "ArrayOfDateTime", propOrder = {
>>>  "dateTime"
>>> })
>>> public class ArrayOfDateTime {
>>>
>>>  @XmlElement(type = String.class)
>>>  @XmlJavaTypeAdapter(CalendarXMLAdapter.class)
>>>  @XmlSchemaType(name = "dateTime")
>>>  protected List<Calendar> dateTime;
>>>
>>>  public List<Calendar> getDateTime() {
>>>      if (dateTime == null) {
>>>          dateTime = new ArrayList<Calendar>();
>>>      }
>>>      return this.dateTime;
>>>  }
>>>
>>> }
>>>
>>> On Mon, May 19, 2008 at 2:56 PM, <ja...@external.t-mobile.at>
>>> wrote:
>>>
>>>  Hello,
>>>>
>>>> see below.
>>>>
>>>> best regards
>>>> jano
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <bindings version="2.1"
>>>>      xmlns="http://java.sun.com/xml/ns/jaxb"
>>>>      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>>>      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>>>>
>>>>>
>>>>>
>>>>      <globalBindings>
>>>>              <xjc:javaType name="java.util.Calendar"
>>>>
>>> xmlType="xsd:date"
>>>
>>>>                      adapter="xxx.common.jaxb.CalendarAdapter" />
>>>>
>>>>              <xjc:javaType name="java.util.Calendar"
>>>>
>>> xmlType="xsd:time"
>>>
>>>>                      adapter="xxx.common.jaxb.CalendarAdapter" />
>>>>
>>>>              <xjc:javaType name="java.util.Calendar"
>>>> xmlType="xsd:dateTime"
>>>>                      adapter="xxx.common.jaxb.CalendarAdapter" />
>>>>      </globalBindings>
>>>> </bindings>
>>>>
>>>>
>>>> package xxx.common.jaxb;
>>>>
>>>> import java.util.Calendar;
>>>>
>>>> import javax.xml.bind.annotation.adapters.XmlAdapter;
>>>>
>>>> public class CalendarAdapter extends XmlAdapter<String, Calendar> {
>>>>
>>>>      public Calendar unmarshal(String value) {
>>>>      return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
>>>>  }
>>>>
>>>>  public String marshal(Calendar value) {
>>>>      if (value == null) {
>>>>          return null;
>>>>      }
>>>>      return (javax.xml.bind.DatatypeConverter.printDateTime(value));
>>>>  }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> "Cord Awtry" <ki...@gmail.com>
>>>> 05/19/2008 20:49
>>>> Bitte antworten an
>>>> users@cxf.apache.org
>>>>
>>>>
>>>> An
>>>> users@cxf.apache.org
>>>> Kopie
>>>>
>>>> Thema
>>>> dateTime custom binding  [Virus checked]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Hello all,
>>>>
>>>> Wondering if someone can lend some advice on an issue I'm seeing (may
>>>> not
>>>> even be an issue, I'm open to that as an answer ;) ). Essentially, I
>>>>
>>> have
>>>
>>>> a
>>>> WSDL being generated by CXF with all my types inline. I have a bunch of
>>>> xs:datetime objects which are being converted to XMLGregorianCalendar
>>>>
>>> when
>>>
>>>> I
>>>> run wsdlToJava. I've done a bunch of research on this, seen several
>>>> solutions and have yet to see anything work. I've copied the code from
>>>>
>>> the
>>>
>>>> cwiki for solving this, but still no resolution. It's possible what I
>>>>
>>> view
>>>
>>>> as the proper resolution may be incorrect. Essentially, I'd like to get
>>>> rid
>>>> of all the instances of XMLGregorianCalendar in my generated java files
>>>> and
>>>> have them be java.util.Date objects. Below is a copy of my bindings that
>>>> I'm
>>>> using with CXF 2.1. If anyone has any thoughts as to why I'm still
>>>>
>>> getting
>>>
>>>> XMLGregorianCalendar objects in my generated java files, I'd be more
>>>>
>>> than
>>>
>>>> happy to hear it.
>>>>
>>>> Thanks,
>>>>
>>>>  -C-
>>>>
>>>> <jaxws:bindings wsdlLocation="
>>>> http://127.0.0.1:8080/ext/services/Extension?wsdl"
>>>>              xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>>>>              xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>>              xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>>>              xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>>>> <jaxws:bindings
>>>> node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
>>>> http://www.tmu.com/services/Extension/2008/05'<
>>>>
>>> http://www.tmu.com/services/Extension/2008/05%27>
>>>
>>>> ]">
>>>>  <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>>> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>>>>    <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
>>>>
>>>> parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
>>>>
>>>>
>>>> printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
>>>
>>>>  </jxb:globalBindings>
>>>> </jaxws:bindings>
>>>> </jaxws:bindings>
>>>>
>>>>
>>>>
>>>
>>>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>
>

Re: dateTime custom binding [Virus checked]

Posted by Daniel Kulp <dk...@apache.org>.
On May 20, 2008, at 1:22 PM, Cord Awtry wrote:

> Hmmm. I'm fairly certain I have it set up right. And those  
> WrapperTypeHelper
> classes are no-where to be found on my system. Do they get created  
> on the
> fly by cxf during the processing?

Yes, they do. We use asm to generate some helper classes to pull data  
in/out of the wrapper classes to deal with the unwrapping.   It's  
quite a bit faster than using reflection to do that all the time.

Dan



>
>
> On Tue, May 20, 2008 at 8:24 AM, <jan.minaroviech@external.t- 
> mobile.at>
> wrote:
>
>> Hello,
>>
>> well, according to my sources, it'll return  
>> java.util.GregorianCalendar
>> (but internally during it's creation also XMLGregorianCalendar is  
>> used)
>>
>> didn't you mixed something?
>> after i used CalendarAdapter (instead of setting parse/print  
>> methods),
>> alll strange classes like  
>> foo.bar.SetOrderCalendarDates_WrapperTypeHelper1
>> has disappeared from my project.
>>
>> best regards
>> jano
>>
>>
>>
>>
>>
>>
>> "Cord Awtry" <ki...@gmail.com>
>> 05/20/2008 14:01
>> Bitte antworten an
>> users@cxf.apache.org
>>
>>
>> An
>> users@cxf.apache.org
>> Kopie
>>
>> Thema
>> Re: dateTime custom binding [Virus checked]
>>
>>
>>
>>
>>
>>
>> Jano,
>>
>> That did the trick, thanks. I'm curious if you or anyone else has any
>> insight on a follow-up question. It would seem the  
>> XMLGregorianCalendar is
>> still in use, at least partially, after using the custom bindings  
>> file to
>> convert them all to java.util.Calendar objects. Below is a
>> ClassCastException with an XMLGregorianCalendar as well as code  
>> snippets
>> from the source.
>>
>> Thanks again,
>>
>>   -C-
>>
>> ***EXCEPTION***
>> Caused by: java.lang.ClassCastException:
>> com 
>> .sun 
>> .org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
>>       at
>>
>> foo 
>> .bar 
>> .SetOrderCalendarDates_WrapperTypeHelper1.createWrapperObject(Unknown
>> Source)
>>       at
>>
>> org 
>> .apache 
>> .cxf 
>> .jaxws 
>> .interceptors 
>> .WrapperClassOutInterceptor 
>> .handleMessage(WrapperClassOutInterceptor.java:102)
>>       ... 49 more
>>
>> ***JAVA OBJECT FOR WS CALL***
>> /**
>> * <p>Java class for anonymous complex type.
>> *
>> * <p>The following schema fragment specifies the expected content
>> contained
>> within this class.
>> *
>> * <pre>
>> * &lt;complexType>
>> *   &lt;complexContent>
>> *     &lt;restriction base="{http://www.w3.org/2001/ 
>> XMLSchema}anyType<http://www.w3.org/2001/XMLSchema%7DanyType>
>> ">
>> *       &lt;sequence>
>> *         &lt;element name="requiredDates"
>> type="{http://bar.foo}ArrayOfDateTime"
>> minOccurs="0"/>
>> *       &lt;/sequence>
>> *     &lt;/restriction>
>> *   &lt;/complexContent>
>> * &lt;/complexType>
>> * </pre>
>> *
>> *
>> */
>> @XmlAccessorType(XmlAccessType.FIELD)
>> @XmlType(name = "", propOrder = {
>>   "requiredDates",
>> })
>> @XmlRootElement(name = "SetOrderCalendarDates")
>> public class SetOrderCalendarDates {
>>   protected ArrayOfDateTime requiredDates;
>> .
>> .
>> .
>> }
>>
>> ***CHILD OBJECT***
>> /**
>> * <p>Java class for ArrayOfDateTime complex type.
>> *
>> * <p>The following schema fragment specifies the expected content
>> contained
>> within this class.
>> *
>> * <pre>
>> * &lt;complexType name="ArrayOfDateTime">
>> *   &lt;complexContent>
>> *     &lt;restriction base="{http://www.w3.org/2001/ 
>> XMLSchema}anyType<http://www.w3.org/2001/XMLSchema%7DanyType>
>> ">
>> *       &lt;sequence>
>> *         &lt;element name="dateTime" type="{
>> http://www.w3.org/2001/XMLSchema}dateTime<http://www.w3.org/2001/XMLSchema%7DdateTime 
>> >"
>> maxOccurs="unbounded"
>> minOccurs="0"/>
>> *       &lt;/sequence>
>> *     &lt;/restriction>
>> *   &lt;/complexContent>
>> * &lt;/complexType>
>> * </pre>
>> *
>> *
>> */
>> @XmlAccessorType(XmlAccessType.FIELD)
>> @XmlType(name = "ArrayOfDateTime", propOrder = {
>>   "dateTime"
>> })
>> public class ArrayOfDateTime {
>>
>>   @XmlElement(type = String.class)
>>   @XmlJavaTypeAdapter(CalendarXMLAdapter.class)
>>   @XmlSchemaType(name = "dateTime")
>>   protected List<Calendar> dateTime;
>>
>>   public List<Calendar> getDateTime() {
>>       if (dateTime == null) {
>>           dateTime = new ArrayList<Calendar>();
>>       }
>>       return this.dateTime;
>>   }
>>
>> }
>>
>> On Mon, May 19, 2008 at 2:56 PM, <jan.minaroviech@external.t-mobile.at 
>> >
>> wrote:
>>
>>> Hello,
>>>
>>> see below.
>>>
>>> best regards
>>> jano
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <bindings version="2.1"
>>>       xmlns="http://java.sun.com/xml/ns/jaxb"
>>>       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>>       xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>>>>
>>>
>>>       <globalBindings>
>>>               <xjc:javaType name="java.util.Calendar"
>> xmlType="xsd:date"
>>>                       adapter="xxx.common.jaxb.CalendarAdapter" />
>>>
>>>               <xjc:javaType name="java.util.Calendar"
>> xmlType="xsd:time"
>>>                       adapter="xxx.common.jaxb.CalendarAdapter" />
>>>
>>>               <xjc:javaType name="java.util.Calendar"
>>> xmlType="xsd:dateTime"
>>>                       adapter="xxx.common.jaxb.CalendarAdapter" />
>>>       </globalBindings>
>>> </bindings>
>>>
>>>
>>> package xxx.common.jaxb;
>>>
>>> import java.util.Calendar;
>>>
>>> import javax.xml.bind.annotation.adapters.XmlAdapter;
>>>
>>> public class CalendarAdapter extends XmlAdapter<String, Calendar> {
>>>
>>>       public Calendar unmarshal(String value) {
>>>       return  
>>> (javax.xml.bind.DatatypeConverter.parseDateTime(value));
>>>   }
>>>
>>>   public String marshal(Calendar value) {
>>>       if (value == null) {
>>>           return null;
>>>       }
>>>       return  
>>> (javax.xml.bind.DatatypeConverter.printDateTime(value));
>>>   }
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>> "Cord Awtry" <ki...@gmail.com>
>>> 05/19/2008 20:49
>>> Bitte antworten an
>>> users@cxf.apache.org
>>>
>>>
>>> An
>>> users@cxf.apache.org
>>> Kopie
>>>
>>> Thema
>>> dateTime custom binding  [Virus checked]
>>>
>>>
>>>
>>>
>>>
>>>
>>> Hello all,
>>>
>>> Wondering if someone can lend some advice on an issue I'm seeing  
>>> (may
>>> not
>>> even be an issue, I'm open to that as an answer ;) ). Essentially, I
>> have
>>> a
>>> WSDL being generated by CXF with all my types inline. I have a  
>>> bunch of
>>> xs:datetime objects which are being converted to  
>>> XMLGregorianCalendar
>> when
>>> I
>>> run wsdlToJava. I've done a bunch of research on this, seen several
>>> solutions and have yet to see anything work. I've copied the code  
>>> from
>> the
>>> cwiki for solving this, but still no resolution. It's possible  
>>> what I
>> view
>>> as the proper resolution may be incorrect. Essentially, I'd like  
>>> to get
>>> rid
>>> of all the instances of XMLGregorianCalendar in my generated java  
>>> files
>>> and
>>> have them be java.util.Date objects. Below is a copy of my  
>>> bindings that
>>> I'm
>>> using with CXF 2.1. If anyone has any thoughts as to why I'm still
>> getting
>>> XMLGregorianCalendar objects in my generated java files, I'd be more
>> than
>>> happy to hear it.
>>>
>>> Thanks,
>>>
>>>   -C-
>>>
>>> <jaxws:bindings wsdlLocation="
>>> http://127.0.0.1:8080/ext/services/Extension?wsdl"
>>>               xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>>>               xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>               xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>>               xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>>> <jaxws:bindings
>>> node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
>>> http://www.tmu.com/services/Extension/2008/05'<
>> http://www.tmu.com/services/Extension/2008/05%27>
>>> ]">
>>>   <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>>>     <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
>>>
>>> parseMethod 
>>> ="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
>>>
>>>
>> printMethod 
>> ="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
>>>   </jxb:globalBindings>
>>> </jaxws:bindings>
>>> </jaxws:bindings>
>>>
>>>
>>
>>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog





Re: Re: dateTime custom binding [Virus checked]

Posted by Cord Awtry <ki...@gmail.com>.
Hmmm. I'm fairly certain I have it set up right. And those WrapperTypeHelper
classes are no-where to be found on my system. Do they get created on the
fly by cxf during the processing?

On Tue, May 20, 2008 at 8:24 AM, <ja...@external.t-mobile.at>
wrote:

> Hello,
>
> well, according to my sources, it'll return java.util.GregorianCalendar
> (but internally during it's creation also XMLGregorianCalendar is used)
>
> didn't you mixed something?
> after i used CalendarAdapter (instead of setting parse/print methods),
> alll strange classes like foo.bar.SetOrderCalendarDates_WrapperTypeHelper1
> has disappeared from my project.
>
> best regards
> jano
>
>
>
>
>
>
> "Cord Awtry" <ki...@gmail.com>
> 05/20/2008 14:01
> Bitte antworten an
> users@cxf.apache.org
>
>
> An
> users@cxf.apache.org
> Kopie
>
> Thema
> Re: dateTime custom binding [Virus checked]
>
>
>
>
>
>
> Jano,
>
>  That did the trick, thanks. I'm curious if you or anyone else has any
> insight on a follow-up question. It would seem the XMLGregorianCalendar is
> still in use, at least partially, after using the custom bindings file to
> convert them all to java.util.Calendar objects. Below is a
> ClassCastException with an XMLGregorianCalendar as well as code snippets
> from the source.
>
>  Thanks again,
>
>    -C-
>
> ***EXCEPTION***
> Caused by: java.lang.ClassCastException:
> com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
>        at
>
> foo.bar.SetOrderCalendarDates_WrapperTypeHelper1.createWrapperObject(Unknown
> Source)
>        at
>
> org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:102)
>        ... 49 more
>
> ***JAVA OBJECT FOR WS CALL***
> /**
>  * <p>Java class for anonymous complex type.
>  *
>  * <p>The following schema fragment specifies the expected content
> contained
> within this class.
>  *
>  * <pre>
>  * &lt;complexType>
>  *   &lt;complexContent>
>  *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType<http://www.w3.org/2001/XMLSchema%7DanyType>
> ">
>  *       &lt;sequence>
>  *         &lt;element name="requiredDates"
> type="{http://bar.foo}ArrayOfDateTime"
> minOccurs="0"/>
>  *       &lt;/sequence>
>  *     &lt;/restriction>
>  *   &lt;/complexContent>
>  * &lt;/complexType>
>  * </pre>
>  *
>  *
>  */
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "", propOrder = {
>    "requiredDates",
> })
> @XmlRootElement(name = "SetOrderCalendarDates")
> public class SetOrderCalendarDates {
>    protected ArrayOfDateTime requiredDates;
> .
> .
> .
> }
>
> ***CHILD OBJECT***
> /**
>  * <p>Java class for ArrayOfDateTime complex type.
>  *
>  * <p>The following schema fragment specifies the expected content
> contained
> within this class.
>  *
>  * <pre>
>  * &lt;complexType name="ArrayOfDateTime">
>  *   &lt;complexContent>
>  *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType<http://www.w3.org/2001/XMLSchema%7DanyType>
> ">
>  *       &lt;sequence>
>  *         &lt;element name="dateTime" type="{
> http://www.w3.org/2001/XMLSchema}dateTime<http://www.w3.org/2001/XMLSchema%7DdateTime>"
> maxOccurs="unbounded"
> minOccurs="0"/>
>  *       &lt;/sequence>
>  *     &lt;/restriction>
>  *   &lt;/complexContent>
>  * &lt;/complexType>
>  * </pre>
>  *
>  *
>  */
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "ArrayOfDateTime", propOrder = {
>    "dateTime"
> })
> public class ArrayOfDateTime {
>
>    @XmlElement(type = String.class)
>    @XmlJavaTypeAdapter(CalendarXMLAdapter.class)
>    @XmlSchemaType(name = "dateTime")
>    protected List<Calendar> dateTime;
>
>    public List<Calendar> getDateTime() {
>        if (dateTime == null) {
>            dateTime = new ArrayList<Calendar>();
>        }
>        return this.dateTime;
>    }
>
> }
>
> On Mon, May 19, 2008 at 2:56 PM, <ja...@external.t-mobile.at>
> wrote:
>
> > Hello,
> >
> > see below.
> >
> > best regards
> > jano
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <bindings version="2.1"
> >        xmlns="http://java.sun.com/xml/ns/jaxb"
> >        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
> >        >
> >
> >        <globalBindings>
> >                <xjc:javaType name="java.util.Calendar"
> xmlType="xsd:date"
> >                        adapter="xxx.common.jaxb.CalendarAdapter" />
> >
> >                <xjc:javaType name="java.util.Calendar"
> xmlType="xsd:time"
> >                        adapter="xxx.common.jaxb.CalendarAdapter" />
> >
> >                <xjc:javaType name="java.util.Calendar"
> > xmlType="xsd:dateTime"
> >                        adapter="xxx.common.jaxb.CalendarAdapter" />
> >        </globalBindings>
> > </bindings>
> >
> >
> > package xxx.common.jaxb;
> >
> > import java.util.Calendar;
> >
> > import javax.xml.bind.annotation.adapters.XmlAdapter;
> >
> > public class CalendarAdapter extends XmlAdapter<String, Calendar> {
> >
> >        public Calendar unmarshal(String value) {
> >        return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
> >    }
> >
> >    public String marshal(Calendar value) {
> >        if (value == null) {
> >            return null;
> >        }
> >        return (javax.xml.bind.DatatypeConverter.printDateTime(value));
> >    }
> >
> > }
> >
> >
> >
> >
> >
> > "Cord Awtry" <ki...@gmail.com>
> > 05/19/2008 20:49
> > Bitte antworten an
> > users@cxf.apache.org
> >
> >
> > An
> > users@cxf.apache.org
> > Kopie
> >
> > Thema
> > dateTime custom binding  [Virus checked]
> >
> >
> >
> >
> >
> >
> > Hello all,
> >
> >  Wondering if someone can lend some advice on an issue I'm seeing (may
> > not
> > even be an issue, I'm open to that as an answer ;) ). Essentially, I
> have
> > a
> > WSDL being generated by CXF with all my types inline. I have a bunch of
> > xs:datetime objects which are being converted to XMLGregorianCalendar
> when
> > I
> > run wsdlToJava. I've done a bunch of research on this, seen several
> > solutions and have yet to see anything work. I've copied the code from
> the
> > cwiki for solving this, but still no resolution. It's possible what I
> view
> > as the proper resolution may be incorrect. Essentially, I'd like to get
> > rid
> > of all the instances of XMLGregorianCalendar in my generated java files
> > and
> > have them be java.util.Date objects. Below is a copy of my bindings that
> > I'm
> > using with CXF 2.1. If anyone has any thoughts as to why I'm still
> getting
> > XMLGregorianCalendar objects in my generated java files, I'd be more
> than
> > happy to hear it.
> >
> >  Thanks,
> >
> >    -C-
> >
> > <jaxws:bindings wsdlLocation="
> > http://127.0.0.1:8080/ext/services/Extension?wsdl"
> >                xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
> >                xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> >                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> >  <jaxws:bindings
> > node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
> > http://www.tmu.com/services/Extension/2008/05'<
> http://www.tmu.com/services/Extension/2008/05%27>
> > ]">
> >    <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema">
> >      <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
> >
> >  parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
> >
> >
> printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
> >    </jxb:globalBindings>
> >  </jaxws:bindings>
> > </jaxws:bindings>
> >
> >
>
>

Antwort: Re: dateTime custom binding [Virus checked]

Posted by ja...@external.t-mobile.at.
Hello,

well, according to my sources, it'll return java.util.GregorianCalendar 
(but internally during it's creation also XMLGregorianCalendar is used)

didn't you mixed something?
after i used CalendarAdapter (instead of setting parse/print methods), 
alll strange classes like foo.bar.SetOrderCalendarDates_WrapperTypeHelper1 
has disappeared from my project.

best regards
jano






"Cord Awtry" <ki...@gmail.com> 
05/20/2008 14:01
Bitte antworten an
users@cxf.apache.org


An
users@cxf.apache.org
Kopie

Thema
Re: dateTime custom binding [Virus checked]






Jano,

  That did the trick, thanks. I'm curious if you or anyone else has any
insight on a follow-up question. It would seem the XMLGregorianCalendar is
still in use, at least partially, after using the custom bindings file to
convert them all to java.util.Calendar objects. Below is a
ClassCastException with an XMLGregorianCalendar as well as code snippets
from the source.

  Thanks again,

    -C-

***EXCEPTION***
Caused by: java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
        at
foo.bar.SetOrderCalendarDates_WrapperTypeHelper1.createWrapperObject(Unknown
Source)
        at
org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:102)
        ... 49 more

***JAVA OBJECT FOR WS CALL***
/**
 * <p>Java class for anonymous complex type.
 *
 * <p>The following schema fragment specifies the expected content 
contained
within this class.
 *
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="requiredDates"
type="{http://bar.foo}ArrayOfDateTime"
minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "requiredDates",
})
@XmlRootElement(name = "SetOrderCalendarDates")
public class SetOrderCalendarDates {
    protected ArrayOfDateTime requiredDates;
.
.
.
}

***CHILD OBJECT***
/**
 * <p>Java class for ArrayOfDateTime complex type.
 *
 * <p>The following schema fragment specifies the expected content 
contained
within this class.
 *
 * <pre>
 * &lt;complexType name="ArrayOfDateTime">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="dateTime" type="{
http://www.w3.org/2001/XMLSchema}dateTime" maxOccurs="unbounded"
minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfDateTime", propOrder = {
    "dateTime"
})
public class ArrayOfDateTime {

    @XmlElement(type = String.class)
    @XmlJavaTypeAdapter(CalendarXMLAdapter.class)
    @XmlSchemaType(name = "dateTime")
    protected List<Calendar> dateTime;

    public List<Calendar> getDateTime() {
        if (dateTime == null) {
            dateTime = new ArrayList<Calendar>();
        }
        return this.dateTime;
    }

}

On Mon, May 19, 2008 at 2:56 PM, <ja...@external.t-mobile.at>
wrote:

> Hello,
>
> see below.
>
> best regards
> jano
>
> <?xml version="1.0" encoding="UTF-8"?>
> <bindings version="2.1"
>        xmlns="http://java.sun.com/xml/ns/jaxb"
>        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>        >
>
>        <globalBindings>
>                <xjc:javaType name="java.util.Calendar" 
xmlType="xsd:date"
>                        adapter="xxx.common.jaxb.CalendarAdapter" />
>
>                <xjc:javaType name="java.util.Calendar" 
xmlType="xsd:time"
>                        adapter="xxx.common.jaxb.CalendarAdapter" />
>
>                <xjc:javaType name="java.util.Calendar"
> xmlType="xsd:dateTime"
>                        adapter="xxx.common.jaxb.CalendarAdapter" />
>        </globalBindings>
> </bindings>
>
>
> package xxx.common.jaxb;
>
> import java.util.Calendar;
>
> import javax.xml.bind.annotation.adapters.XmlAdapter;
>
> public class CalendarAdapter extends XmlAdapter<String, Calendar> {
>
>        public Calendar unmarshal(String value) {
>        return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
>    }
>
>    public String marshal(Calendar value) {
>        if (value == null) {
>            return null;
>        }
>        return (javax.xml.bind.DatatypeConverter.printDateTime(value));
>    }
>
> }
>
>
>
>
>
> "Cord Awtry" <ki...@gmail.com>
> 05/19/2008 20:49
> Bitte antworten an
> users@cxf.apache.org
>
>
> An
> users@cxf.apache.org
> Kopie
>
> Thema
> dateTime custom binding  [Virus checked]
>
>
>
>
>
>
> Hello all,
>
>  Wondering if someone can lend some advice on an issue I'm seeing (may
> not
> even be an issue, I'm open to that as an answer ;) ). Essentially, I 
have
> a
> WSDL being generated by CXF with all my types inline. I have a bunch of
> xs:datetime objects which are being converted to XMLGregorianCalendar 
when
> I
> run wsdlToJava. I've done a bunch of research on this, seen several
> solutions and have yet to see anything work. I've copied the code from 
the
> cwiki for solving this, but still no resolution. It's possible what I 
view
> as the proper resolution may be incorrect. Essentially, I'd like to get
> rid
> of all the instances of XMLGregorianCalendar in my generated java files
> and
> have them be java.util.Date objects. Below is a copy of my bindings that
> I'm
> using with CXF 2.1. If anyone has any thoughts as to why I'm still 
getting
> XMLGregorianCalendar objects in my generated java files, I'd be more 
than
> happy to hear it.
>
>  Thanks,
>
>    -C-
>
> <jaxws:bindings wsdlLocation="
> http://127.0.0.1:8080/ext/services/Extension?wsdl"
>                xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>                xmlns:xs="http://www.w3.org/2001/XMLSchema"
>                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>  <jaxws:bindings
> node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
> http://www.tmu.com/services/Extension/2008/05'<
http://www.tmu.com/services/Extension/2008/05%27>
> ]">
>    <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>      <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
>
>  parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
>
> 
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
>    </jxb:globalBindings>
>  </jaxws:bindings>
> </jaxws:bindings>
>
>


Re: dateTime custom binding [Virus checked]

Posted by Cord Awtry <ki...@gmail.com>.
Jano,

  That did the trick, thanks. I'm curious if you or anyone else has any
insight on a follow-up question. It would seem the XMLGregorianCalendar is
still in use, at least partially, after using the custom bindings file to
convert them all to java.util.Calendar objects. Below is a
ClassCastException with an XMLGregorianCalendar as well as code snippets
from the source.

  Thanks again,

    -C-

***EXCEPTION***
Caused by: java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
        at
foo.bar.SetOrderCalendarDates_WrapperTypeHelper1.createWrapperObject(Unknown
Source)
        at
org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:102)
        ... 49 more

***JAVA OBJECT FOR WS CALL***
/**
 * <p>Java class for anonymous complex type.
 *
 * <p>The following schema fragment specifies the expected content contained
within this class.
 *
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="requiredDates"
type="{http://bar.foo}ArrayOfDateTime"
minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "requiredDates",
})
@XmlRootElement(name = "SetOrderCalendarDates")
public class SetOrderCalendarDates {
    protected ArrayOfDateTime requiredDates;
.
.
.
}

***CHILD OBJECT***
/**
 * <p>Java class for ArrayOfDateTime complex type.
 *
 * <p>The following schema fragment specifies the expected content contained
within this class.
 *
 * <pre>
 * &lt;complexType name="ArrayOfDateTime">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="dateTime" type="{
http://www.w3.org/2001/XMLSchema}dateTime" maxOccurs="unbounded"
minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfDateTime", propOrder = {
    "dateTime"
})
public class ArrayOfDateTime {

    @XmlElement(type = String.class)
    @XmlJavaTypeAdapter(CalendarXMLAdapter.class)
    @XmlSchemaType(name = "dateTime")
    protected List<Calendar> dateTime;

    public List<Calendar> getDateTime() {
        if (dateTime == null) {
            dateTime = new ArrayList<Calendar>();
        }
        return this.dateTime;
    }

}

On Mon, May 19, 2008 at 2:56 PM, <ja...@external.t-mobile.at>
wrote:

> Hello,
>
> see below.
>
> best regards
> jano
>
> <?xml version="1.0" encoding="UTF-8"?>
> <bindings version="2.1"
>        xmlns="http://java.sun.com/xml/ns/jaxb"
>        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>        >
>
>        <globalBindings>
>                <xjc:javaType name="java.util.Calendar" xmlType="xsd:date"
>                        adapter="xxx.common.jaxb.CalendarAdapter" />
>
>                <xjc:javaType name="java.util.Calendar" xmlType="xsd:time"
>                        adapter="xxx.common.jaxb.CalendarAdapter" />
>
>                <xjc:javaType name="java.util.Calendar"
> xmlType="xsd:dateTime"
>                        adapter="xxx.common.jaxb.CalendarAdapter" />
>        </globalBindings>
> </bindings>
>
>
> package xxx.common.jaxb;
>
> import java.util.Calendar;
>
> import javax.xml.bind.annotation.adapters.XmlAdapter;
>
> public class CalendarAdapter extends XmlAdapter<String, Calendar> {
>
>        public Calendar unmarshal(String value) {
>        return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
>    }
>
>    public String marshal(Calendar value) {
>        if (value == null) {
>            return null;
>        }
>        return (javax.xml.bind.DatatypeConverter.printDateTime(value));
>    }
>
> }
>
>
>
>
>
> "Cord Awtry" <ki...@gmail.com>
> 05/19/2008 20:49
> Bitte antworten an
> users@cxf.apache.org
>
>
> An
> users@cxf.apache.org
> Kopie
>
> Thema
> dateTime custom binding  [Virus checked]
>
>
>
>
>
>
> Hello all,
>
>  Wondering if someone can lend some advice on an issue I'm seeing (may
> not
> even be an issue, I'm open to that as an answer ;) ). Essentially, I have
> a
> WSDL being generated by CXF with all my types inline. I have a bunch of
> xs:datetime objects which are being converted to XMLGregorianCalendar when
> I
> run wsdlToJava. I've done a bunch of research on this, seen several
> solutions and have yet to see anything work. I've copied the code from the
> cwiki for solving this, but still no resolution. It's possible what I view
> as the proper resolution may be incorrect. Essentially, I'd like to get
> rid
> of all the instances of XMLGregorianCalendar in my generated java files
> and
> have them be java.util.Date objects. Below is a copy of my bindings that
> I'm
> using with CXF 2.1. If anyone has any thoughts as to why I'm still getting
> XMLGregorianCalendar objects in my generated java files, I'd be more than
> happy to hear it.
>
>  Thanks,
>
>    -C-
>
> <jaxws:bindings wsdlLocation="
> http://127.0.0.1:8080/ext/services/Extension?wsdl"
>                xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
>                xmlns:xs="http://www.w3.org/2001/XMLSchema"
>                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
>                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>  <jaxws:bindings
> node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
> http://www.tmu.com/services/Extension/2008/05'<http://www.tmu.com/services/Extension/2008/05%27>
> ]">
>    <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>      <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
>
>  parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
>
>  printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
>    </jxb:globalBindings>
>  </jaxws:bindings>
> </jaxws:bindings>
>
>

Re: dateTime custom binding

Posted by Ch...@sybase.com.
You need to create a customer binding file for your web service. You can 
use the following as a guide but change the relevant information to your 
specific needs.
For example: wsldLoction needs to be your services URL, and the 
targetNamespace must match your services namespace.

<jaxws:bindings 
wsdlLocation="http://localhost:8080/applicationContext/services/serviceName?wsdl"
          xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <jaxws:bindings 
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://your.service.namespace.com']">
      <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <jxb:serializable/>
        <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
 parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
 printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
      </jxb:globalBindings>
  </jaxws:bindings>
</jaxws:bindings>


Next, you need to tell wsdl2java about the binding. For example:
.\wsdl2java.bat -client -d s:\cxf-client\src -b 
s:\cxf-client\yourServiceBinding.xml -validate 
http://localhost:8080/applicationContext/services/serviceName?wsdl

wsdl2java will then apply the binding to your generated classes.

I hope this helps...

Chris 




"Cord Awtry" <ki...@gmail.com> 
05/19/2008 11:49 AM
Please respond to
users@cxf.apache.org


To
users@cxf.apache.org
cc

Subject
dateTime custom binding






Hello all,

  Wondering if someone can lend some advice on an issue I'm seeing (may 
not
even be an issue, I'm open to that as an answer ;) ). Essentially, I have 
a
WSDL being generated by CXF with all my types inline. I have a bunch of
xs:datetime objects which are being converted to XMLGregorianCalendar when 
I
run wsdlToJava. I've done a bunch of research on this, seen several
solutions and have yet to see anything work. I've copied the code from the
cwiki for solving this, but still no resolution. It's possible what I view
as the proper resolution may be incorrect. Essentially, I'd like to get 
rid
of all the instances of XMLGregorianCalendar in my generated java files 
and
have them be java.util.Date objects. Below is a copy of my bindings that 
I'm
using with CXF 2.1. If anyone has any thoughts as to why I'm still getting
XMLGregorianCalendar objects in my generated java files, I'd be more than
happy to hear it.

  Thanks,

    -C-

<jaxws:bindings wsdlLocation="
http://127.0.0.1:8080/ext/services/Extension?wsdl"
                xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
http://www.tmu.com/services/Extension/2008/05']">
    <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"

 parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"

 printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
    </jxb:globalBindings>
  </jaxws:bindings>
</jaxws:bindings>


Antwort: dateTime custom binding [Virus checked]

Posted by ja...@external.t-mobile.at.
Hello,

see below.

best regards
jano

<?xml version="1.0" encoding="UTF-8"?>
<bindings version="2.1"
        xmlns="http://java.sun.com/xml/ns/jaxb" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
        >

        <globalBindings>
                <xjc:javaType name="java.util.Calendar" xmlType="xsd:date"
                        adapter="xxx.common.jaxb.CalendarAdapter" />
 
                <xjc:javaType name="java.util.Calendar" xmlType="xsd:time"
                        adapter="xxx.common.jaxb.CalendarAdapter" />
 
                <xjc:javaType name="java.util.Calendar" 
xmlType="xsd:dateTime"
                        adapter="xxx.common.jaxb.CalendarAdapter" />
        </globalBindings>
</bindings>


package xxx.common.jaxb;

import java.util.Calendar;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class CalendarAdapter extends XmlAdapter<String, Calendar> {

        public Calendar unmarshal(String value) {
        return (javax.xml.bind.DatatypeConverter.parseDateTime(value));
    }

    public String marshal(Calendar value) {
        if (value == null) {
            return null;
        }
        return (javax.xml.bind.DatatypeConverter.printDateTime(value));
    }

}





"Cord Awtry" <ki...@gmail.com> 
05/19/2008 20:49
Bitte antworten an
users@cxf.apache.org


An
users@cxf.apache.org
Kopie

Thema
dateTime custom binding  [Virus checked]






Hello all,

  Wondering if someone can lend some advice on an issue I'm seeing (may 
not
even be an issue, I'm open to that as an answer ;) ). Essentially, I have 
a
WSDL being generated by CXF with all my types inline. I have a bunch of
xs:datetime objects which are being converted to XMLGregorianCalendar when 
I
run wsdlToJava. I've done a bunch of research on this, seen several
solutions and have yet to see anything work. I've copied the code from the
cwiki for solving this, but still no resolution. It's possible what I view
as the proper resolution may be incorrect. Essentially, I'd like to get 
rid
of all the instances of XMLGregorianCalendar in my generated java files 
and
have them be java.util.Date objects. Below is a copy of my bindings that 
I'm
using with CXF 2.1. If anyone has any thoughts as to why I'm still getting
XMLGregorianCalendar objects in my generated java files, I'd be more than
happy to hear it.

  Thanks,

    -C-

<jaxws:bindings wsdlLocation="
http://127.0.0.1:8080/ext/services/Extension?wsdl"
                xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='
http://www.tmu.com/services/Extension/2008/05']">
    <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <jxb:javaType name="java.util.Date" xmlType="xs:dateTime"

 parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"

 printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>
    </jxb:globalBindings>
  </jaxws:bindings>
</jaxws:bindings>