views:

1414

answers:

3

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?

A: 

According to the IBM docs you are right, both date and dateTime map to Calendar. There doesn't seem to be a standard way to use only the date part, of course you could roll your own (interestingly the second page of the referenced article says date is for dates only but page 3 confirms it maps to Calendar).

For reference there's a similar question about doing this in WCF.

Rich Seller
Thank you for this answer, it is helpful, but doesn't directly help me solve my problem of how to make the web service expose a wsdl with an xs:date field. The client application requested that the wsdl expose a date only, not dateTime.
Jason w
+1  A: 

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.

skaffman
A: 

I actually did figure out how to do this properly.

in the WEB-INF/wsdl/(schemaname).xsd I changed the datatype to date from dateTime and redeploy the service and it works with my existing java.util.Calendar types.

Jason w