客户端CXF IllegalArgumentException XMLGregorianCalendarImpl dateTime

时间:2013-10-08 19:26:59

标签: java spring web-services client cxf

我在使用Java 1.6上的CXF 2.7.7进行Web服务时遇到问题

错误说:

java.lang.IllegalArgumentException: 
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseAndSetYear(XMLGregorianCalendarImpl.java:2850)
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(XMLGregorianCalendarImpl.java:2737)
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:433)
at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:532)
at  com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$12.parse(RuntimeBuiltinLeafInfoImpl.java:479)

我认为这个问题与WSDL的XSD中的dateTime类型元素有关

<element name="audFecCreac" type="dateTime" minOccurs="0" nillable="true" />

使用SOAPUI,我看到了

 <audFecCreac>2013-10-07T14:37:19.000-03:00</audFecCreac>

我在java 1.6上使用wsdl2java命令行创建了客户端

wsdl2java -d D:\mysource -frontend jaxws21 -b bindings.txt http://myserver:8011/myservice?wsdl

使用maven编译并使用此依赖项(制作jar)

<dependencies>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>2.7.7</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>2.7.7</version>
    </dependency>

</dependencies>

和bindings.txt文件

<jaxb:bindings version="2.1" 
  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:globalBindings generateElementProperty="false"/> 
</jaxb:bindings> 

我使用Spring 3.2.4.RELEASE

实现客户端
    <bean id="myWS" class="my.package.InterfaceEndpoint" factory-bean="myWSFactory" factory-method="create"/>
<bean id="myWSFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
     <property name="serviceClass" value="my.package.InterfaceEndpoint"/>
     <property name="address" value="http://myserver:8011/myservice?wsdl"/>
</bean> 

感谢您的回复

0 个答案:

没有答案