sdo*_*oca 10 java cxf wsdl2java
我是CXF的新手,我正在尝试从WSDL创建一个客户端.我过去使用过Metro和Axis.我下载了apache-cxf-2.3.3并使用wsdl2java生成客户端存根.我使用Maven并用它来设置我的pom:
<properties>
<cxf.version>2.3.3</cxf.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<optimize>true</optimize>
<debug>true</debug>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,我得到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project client-cxf: Compilation failure: Compilation failure:
[ERROR] \Devel\Projects\Client-CXF\src\main\java\my\webservice\ServiceRuntimeException.java:[38,149] cannot find symbol
[ERROR] symbol : method required()
Run Code Online (Sandbox Code Playgroud)
和
[ERROR] \Devel\Projects\Client-CXF\src\main\java\my\snmpv2\MyService.java:[76,8] cannot find symbol
[ERROR] symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
[ERROR] location: class javax.xml.ws.Service
Run Code Online (Sandbox Code Playgroud)
似乎问题与生成的代码使用Java 6特性(XmlElementRef的"require"元素,Service的新构造函数)这一事实有关,但CXF Maven依赖关系是针对Java 5的.
有没有办法指定生成的代码应该符合Java 5?
Dan*_*ulp 25
实际上,CXF的wsdl2java命令行工具与Java 5兼容的代码,它可能与Java 6不兼容.原因是它生成的代码符合JAX-WS 2.2和JAXB 2.2.但是,Java 6中包含的那些API的版本仅为2.1.
有几个选择:
1)最简单的方法是在wsdl2java命令中添加"-fe jaxws21",使其生成符合jaxws 2.1标准的代码,而不是2.2
2)将2.2 api jar添加到JDK的endorsed目录中
3)在maven中配置编译器插件以"认可"2.2罐
| 归档时间: |
|
| 查看次数: |
16564 次 |
| 最近记录: |