OK, I've found a solution. Switching to a JAX-WS Client solved the problem
(even if I don't understand exactly yet whats going on here).
The code creating my client proxy now is:
ctx = new
ClassPathXmlApplicationContext("test/wstest-client-context.xml" );
String url = "http://localhost:8080/FooService";
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(FooServiceDocument.class);
factory.setAddress(url);
client = (FooServiceDocument) factory.create();
(borrowed from CXFs user guide :)) This way the client works as expected.
Uwe
> -----Ursprüngliche Nachricht-----
> Von: Maurer Uwe [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 20. Juni 2008 11:23
> An: [email protected]
> Betreff: javax.xml.bind.JAXBException: java.sql.Date is not
> known to this context
>
>
> Hello,
>
> I like to write a test client for my Webservice using CXF 2.1.
>
> This is the code creating my client proxy:
>
> ctx = new
> ClassPathXmlApplicationContext("test/wstest-client-context.xml"
> );
> String url = "http://localhost:8080/FooService";
> ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
>
> factory.setServiceClass(KonzessionsAbgabenSatzBereitstellenV1D
> ocument.class)
> ;
> factory.setAddress(url);
> client = (FooServiceDocument) factory.create();
>
> The Interface FooServiceDocument is the webservice interface
> generated from the WSDL2Java Tool. I use the following JAXB
> binding file to map xs:dateTime to java.sql.Date:
>
> <jaxb:bindings version="2.0"
> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <jaxb:bindings
> schemaLocation="porttypes/Http_FooService_document.wsdl">
> <jaxb:bindings node="/xs:schema">
> <jaxb:globalBindings>
>
> <xjc:generateElementProperty>false</xjc:generateElementProperty>
> <jaxb:javaType name="java.sql.Date"
> xmlType="xs:dateTime"
>
> parseMethod="com.enbw.foo.soa.tools.wsdl2java.DateConverter.pa
> rseDateTime"
>
> printMethod="com.enbw.foo.soa.tools.wsdl2java.DateConverter.pr
> intDateTime"/>
> </jaxb:globalBindings>
> </jaxb:bindings>
> </jaxb:bindings>
> </jaxb:bindings>
>
>
> This is the code calling the service:
>
> ...
> java.sql.Date now = new java.sql.Date(System.currentTimeMillis());
> ArrayOfFoo result = client.getFoo("DE", now, now);
> assertNotNull(result);
> ...
>
>
> Running my client i get an JAXBException at the line where I
> call the client
> ("client.getFoo(...)"):
>
> [javax.xml.bind.JAXBException: java.sql.Date is not known to
> this context]
> at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImp
> l.java:331)
> at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerI
> mpl.java:257)
> at
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Abstract
> MarshallerImpl
> .java:75)
> at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoder
> Decoder.java:4
> 36)
> at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDec
> oder.java:189)
> ... 28 more
> Caused by: javax.xml.bind.JAXBException: java.sql.Date is not
> known to this context
> at
> com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSeria
> lizer.java:242
> )
> at
> com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSeria
> lizer.java:257
> )
> at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBod
> y(ElementBeanI
> nfoImpl.java:143)
> at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBod
> y(ElementBeanI
> nfoImpl.java:185)
> at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(
> ElementBeanInf
> oImpl.java:305)
> at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(
> ElementBeanInf
> oImpl.java:312)
> at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(
> ElementBeanInf
> oImpl.java:71)
> at
> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSeria
> lizer.java:490
> )
> at
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImp
> l.java:328)
> ... 32 more
> Caused by: javax.xml.bind.JAXBException: java.sql.Date is not
> known to this context
> at
> com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBCo
> ntextImpl.java
> :587)
> at
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBod
> y(ElementBeanI
> nfoImpl.java:140)
> ... 38 more
>
> I searched in the list archive but didn't find a real answer
> to my problem. java.sql.Date is part of the jdk 1.5, so I
> assume it's not a class loading problem.
>
> Any hints?
>
> Uwe
>
>