cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Swor (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CXF-369) xsd:dateTime becomes XMLGregorianCalendarImpl when Date needed
Date Wed, 03 Feb 2010 17:17:28 GMT

    [ https://issues.apache.org/jira/browse/CXF-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12829147#action_12829147
] 

Steven Swor edited comment on CXF-369 at 2/3/10 5:15 PM:
---------------------------------------------------------

I get the same error in CXF 2.2.3 when using Aegis data binding on both the client and server.

Here's my setup:
{code:title=Service.java}
@WebService
public interface FooService {
    public Foo getDataByStringAndMap(String name, Map<String, Object> map);
}
{code}

And here's a snippet from my server's Spring config file that sets up the service to use CXF
with Aegis data binding:

{code:xml|title=Spring Configuration File Snippet}
...
<bean id="AegisDataBinding" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype">
	<property name="aegisContext">
	    <bean class="org.apache.cxf.aegis.AegisContext">
		<property name="writeXsiTypes" value="true" />
	    </bean>
	</property>
    </bean>

    <bean id="ServiceFactoryBean" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
	<property name="dataBinding">
	    <ref bean="AegisDataBinding" />
	</property>
	<property name="serviceConfigurations">
	    <list>
		<bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
		<bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
		<bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
	    </list>
	</property>
    </bean>
    <jaxws:endpoint id="FooServiceEndpoint" implementor="#FooService" address="/FooService">
	<jaxws:serviceFactory>
	    <ref bean="ServiceFactoryBean" />
	</jaxws:serviceFactory>
    </jaxws:endpoint>
...
{code}

The client is also configured to use CXF with Aegis data binding.  Here's the SOAP message
sent from the CXF client:

{code:xml|title=Client SOAP Message}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns1:getDataByStringAndMap xmlns:ns1="http://foo.bar.com/">
            <ns1:arg0>name</ns1:arg0>
            <ns1:arg1>
                <ns1:entry>
                    <ns1:key>dateFieldName</ns1:key>
                    <ns1:value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance"
ns2:type="xsd:dateTime">2010-01-01T00:00:00-06:00</ns1:value>
                 </ns1:entry>
            </ns1:arg1>
        </ns1:getDataByStringAndMap>
    </soap:Body>
</soap:Envelope>
{code}

When the client tries to invoke the service method, the service logs the following exception:
{noformat}
Feb 3, 2010 10:00:51 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
WARNING: Application has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
cannot be cast to java.util.Date
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:148)
        at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:83)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:114)
        at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:55)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:98)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104)
        at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:452)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:196)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:220)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:153)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.service(AbstractCXFServlet.java:211)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
cannot be cast to java.util.Date
        at com.foo.FooImpl.getDataFromMap(FooImpl.java:50)
        at com.foo.FooServiceImpl.getDataByStringAndMap(FooServiceImpl.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:166)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82)
        ... 32 more
{noformat}

My FooImpl.getDataFromMap(Map<String, Object>) performs a cast from java.lang.Object
to java.util.Date on line 50 (a Date object is expected here).  It works just fine if the
client has a direct reference to the service object, but when it goes over CXF, I get the
error shown above.  Looking at the SOAP message, it appears that CXF on the client side is
converting java.util.Date to XML correctly, but CXF on the server side is converting the XML
back to an instance of javax.xml.datatype.XMLGregorianCalendar instead of java.util.Date.

      was (Author: sworisbreathing):
    I get the same error when using Aegis data binding on both the client and server.

Here's my setup:
{code:title=Service.java}
@WebService
public interface FooService {
    public Foo getDataByStringAndMap(String name, Map<String, Object> map);
}
{code}

And here's a snippet from my server's Spring config file that sets up the service to use CXF
with Aegis data binding:

{code:xml|title=Spring Configuration File Snippet}
...
<bean id="AegisDataBinding" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype">
	<property name="aegisContext">
	    <bean class="org.apache.cxf.aegis.AegisContext">
		<property name="writeXsiTypes" value="true" />
	    </bean>
	</property>
    </bean>

    <bean id="ServiceFactoryBean" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
	<property name="dataBinding">
	    <ref bean="AegisDataBinding" />
	</property>
	<property name="serviceConfigurations">
	    <list>
		<bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
		<bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
		<bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
	    </list>
	</property>
    </bean>
    <jaxws:endpoint id="FooServiceEndpoint" implementor="#FooService" address="/FooService">
	<jaxws:serviceFactory>
	    <ref bean="ServiceFactoryBean" />
	</jaxws:serviceFactory>
    </jaxws:endpoint>
...
{code}

The client is also configured to use CXF with Aegis data binding.  Here's the SOAP message
sent from the CXF client:

{code:xml|title=Client SOAP Message}
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns1:getDataByStringAndMap xmlns:ns1="http://foo.bar.com/">
            <ns1:arg0>name</ns1:arg0>
            <ns1:arg1>
                <ns1:entry>
                    <ns1:key>dateFieldName</ns1:key>
                    <ns1:value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance"
ns2:type="xsd:dateTime">2010-01-01T00:00:00-06:00</ns1:value>
                 </ns1:entry>
            </ns1:arg1>
        </ns1:getDataByStringAndMap>
    </soap:Body>
</soap:Envelope>
{code}

When the client tries to invoke the service method, the service logs the following exception:
{noformat}
Feb 3, 2010 10:00:51 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
WARNING: Application has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
cannot be cast to java.util.Date
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:148)
        at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:83)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:114)
        at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:55)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:98)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104)
        at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:452)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:196)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:220)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:153)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at org.apache.cxf.transport.servlet.AbstractCXFServlet.service(AbstractCXFServlet.java:211)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
cannot be cast to java.util.Date
        at com.foo.FooImpl.getDataFromMap(FooImpl.java:50)
        at com.foo.FooServiceImpl.getDataByStringAndMap(FooServiceImpl.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:166)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82)
        ... 32 more
{noformat}

My FooImpl.getDataFromMap(Map<String, Object>) performs a cast from java.lang.Object
to java.util.Date on line 50 (a Date object is expected here).  It works just fine if the
client has a direct reference to the service object, but when it goes over CXF, I get the
error shown above.  Looking at the SOAP message, it appears that CXF on the client side is
converting java.util.Date to XML correctly, but CXF on the server side is converting the XML
back to an instance of javax.xml.datatype.XMLGregorianCalendar instead of java.util.Date.
  
> xsd:dateTime becomes XMLGregorianCalendarImpl when Date needed
> --------------------------------------------------------------
>
>                 Key: CXF-369
>                 URL: https://issues.apache.org/jira/browse/CXF-369
>             Project: CXF
>          Issue Type: Bug
>          Components: Soap Binding
>    Affects Versions: 2.0-RC
>         Environment: svn head, jax-ws api, annotations
>            Reporter: Cameron Taggart
>            Assignee: maomaode
>             Fix For: 2.0.1
>
>
> I have a web method:
> public Date echoDate(String sessionID, Date input);
> The soapUI 1.6 client works, but the Axis 1.3 client passes in xsi:type="xsd:dateTime".
 The CXF server turns the dateTime into a XMLGregorianCalendarImpl instead of a date when
that is set.  AbstractInvoker then fails at this call res = m.invoke(serviceObject, paramArray);
with an IllegalArgumentException.
> Here is the full request that does not work:
> <soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <soapenv:Body>
> <echoDate xmlns="urn:TestService/wsdl">
> <sessionID>2CE0B857-43D1-F488-0E0A-F055FDCB8294</sessionID>
> <input xsi:type="xsd:dateTime">2008-01-19T00:29:48.889Z</input>
> </echoDate>
> </soapenv:Body>
> </soapenv:Envelope>
> Failure Response
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Body>
>       <soap:Fault>
>          <faultcode>soap:Server</faultcode>
>          <faultstring>argument type mismatch</faultstring>
>       </soap:Fault>
>    </soap:Body>
> </soap:Envelope>
> Removing 'xsi:type="xsd:dateTime"' makes it work.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message