Java web service, xsd date instead of dateTime

jasonmw picture jasonmw · Jul 26, 2009 · Viewed 9.2k times · Source

In Java EE 1.4 using JAX-RPC 1.1, how can i expose web service, so the wsdl has a complex type (person) where one of the properties of the person is a date which is shown in the WSDL/XSD as only a date (such as a birthdate) instead of a dateTime (where the time is not wanted) in the WSDL/XSD?

i would like the xsd referenced in the wsdl to have

<xs:element name="birthdate" type="xs:date"/>

instead of

<xs:element name="birthdate" type="xs:dateTime"/>

java.util.Calendar and java.util.Date both seem to cause the xsd datatype to be dateTime when rendered in in wsdl/xsd.

I know java EE 1.4 doesnt have the annotations like java EE 5, but is there any way to tell the web service to use the xs:date datatype?

Answer

skaffman picture skaffman · Jul 27, 2009

I don't think you'll be able to achieve this, JAX-RPC just doesn't have the flexibility (which is why it was killed in JavaEE 5).

In general, I usually find that WSDL generators do not have the expressive power to generate the exact WSDl I want, and so I tend to use them to generate a WSDL as a starting point, and then modifying the result. You then server up the WSDL as a static file rather than as a generated one. It's not ideal, but it's not a big deal either.