3

I have a WSDL and created a web service from it using CXF in Eclipse. The execution went fine: no output in the console, I don't know if there is a log somewhere but I could not find one. But in the service interface created, everywhere an XMLGregorianCalendar is used (as either parameter or return value), I get this error from Eclipse:

Abstract class javax.xml.datatype.XMLGregorianCalendar cannot be used as a runtime class because it is not extended by a non abstract class which is suitable as a runtime class

The use of XMLGregorialCalendar in the beans causes no problem, just in the interface. The WSDL was originally created by the same environment (so I am assuming is OK).

I have no idea what this error means! Is it a bug in CXF, a setting I set wrong, or some code I need to add now that the skeleton is created?

Frigg
  • 369
  • 1
  • 3
  • 12

2 Answers2

1

That happens because you are using defaults. You can specify what type you want in bindings file.

Here is an example exert (notice how I tell to use java.util.Date class for "xs:dateTime"):

<jaxws:globalBindings>
    <jaxws:javaType name="java.util.Date" xmlType="xs:dateTime"
        parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
        printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime" />
    <jaxws:javaType name="java.lang.Integer" xmlType="xs:gYear" />
    <jaxws:javaType name="java.lang.Integer" xmlType="xs:positiveInteger" />
    <jaxws:javaType name="java.lang.Integer" xmlType="xs:integer" />
    <jaxws:javaType name="java.lang.Integer" xmlType="xs:int" />
    <jaxws:javaType name="java.util.Locale" xmlType="xs:language" />
</jaxws:globalBindings>

You can read more about JAXWS Customization and Customizing JAXB Bindings

user1697575
  • 2,830
  • 1
  • 24
  • 37
  • OK, so that is an automated way to do what I did manually to fix the problem, thank you. But that means the defaults are wrong! Why use a default that produces the wrong code? This is not an exotic type. – Frigg Mar 19 '14 at 20:14
  • I figured it out. The original WSDL was created with CXF, which did create an external binding file to fix the date problem, but I did not have it. – Frigg Mar 20 '14 at 16:38
  • @Frigg where did you finde the external binding file ? – kozla13 Aug 26 '14 at 15:28
1

This is the actual binding file generated by CXF (if it helps anyone):

<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <jxb:bindings schemaLocation="example_schema1.xsd" node="/xs:schema">
        <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.xjc.runtime.DataTypeAdapter.parseDateTime"
            printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime"/>
    </jxb:globalBindings>
  </jxb:bindings>
</jxb:bindings>
Frigg
  • 369
  • 1
  • 3
  • 12