2

我在 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> 

感谢您的任何回复

4

0 回答 0