JAXB custom type mapping in JBossWS client not working quest
joff Oct 19, 2009 2:53 AMHi, I hope someone on here can help with this one.
I'm trying to use JAXB to map xsd:date and xsd:time types in a WSDL I've been provided with, to a type more sensible than XMLGregorianCalendar, in my case Joda LocalTime and LocalDate types.
I have a binding xml file that looks like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0" targetNamespace="urn:DefaultNamespace"> <xs:annotation > <xs:appinfo> <jaxb:globalBindings> <jaxb:javaType name="org.joda.time.LocalDate" xmlType="xs:date" parseMethod="bookit.util.DateTimeUtil.parseLocalDate" printMethod="bookit.util.DateTimeUtil.printLocalDate"/> <jaxb:javaType name="org.joda.time.LocalTime" xmlType="xs:time" parseMethod="bookit.util.DateTimeUtil.parseLocalTime" printMethod="bookit.util.DateTimeUtil.printLocalTime"/> </jaxb:globalBindings> </xs:appinfo> </xs:annotation> </xs:schema>
With my own parse/print static methods defined on my DateTimeUtil class.
I can successfully run the WSDL through wsimport, and this seems to generate the service interface with methods that look like:
@WebService(name = "AppointmentService", targetNamespace = "urn:DefaultNamespace") @SOAPBinding(style = SOAPBinding.Style.RPC) @XmlSeeAlso({ ObjectFactory.class }) public interface AppointmentService { ... @WebMethod(operationName = "GETAPPOINTMENTS") @WebResult(name = "GETAPPOINTMENTSReturn", partName = "GETAPPOINTMENTSReturn") public XsdAnyTypeArray getappointments( @WebParam(name = "ADVISER", partName = "ADVISER") String adviser, @XmlJavaTypeAdapter(Adapter1 .class) @WebParam(name = "STARTDATE", partName = "STARTDATE") LocalDate startdate, @XmlJavaTypeAdapter(Adapter1 .class) @WebParam(name = "ENDDATE", partName = "ENDDATE") LocalDate enddate); ... }
and the generated Adapter classes use my parse/print methods.
However, when I use this as a client, the adapters don't seem to be used, i.e. the SOAP request comes out looking like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:DefaultNamespace"> <soapenv:Header/> <soapenv:Body> <urn:GETAPPOINTMENTS> <ADVISER>myuser</ADVISER> <STARTDATE/> <ENDDATE/> </urn:GETAPPOINTMENTS> </soapenv:Body> </soapenv:Envelope>
Is there something else I need to be doing to make this work?
I'm currently using JDK6, Seam 2.1.2, and JBoss 4.2.2 (with the jboss-jaxws.jar etc in endorsed). I've also tried this on JBoss 5.0, but with the same result.