CXF wsdl2java

wsdl2java -frontend jaxws21 -p com.monica.bussiness.ticket.service -d d:/build http://localhost:8081/AWS/tktDataExportToKd?wsdl

wsdl2java -frontend jaxws21 -p com.cxf.esb.wsdl2java -d src -client OrderService.wsdl


1、下载apache-cxf-2.6.2在环境变量中配置CXF_HOME ,在PATH中加入%CXF_HOME%\bin

2、输入cmd 进入控制窗口,输入wsdl2java看是否配置成功

3、参考它的文档看这个工具的具体参数的用法
wsdl2java用法:
wsdl2java -p com -d src -all  aa.wsdl
-p  指定其wsdl的命名空间,也就是要生成代码的包名:
-d  指定要产生代码所在目录
-client 生成客户端测试web service的代码
-server 生成服务器启动web  service的代码
-impl 生成web service的实现代码
-ant  生成build.xml文件
-all 生成所有开始端点代码:types,service proxy,,service interface, server mainline, client mainline, implementation object, and an Ant build.xml file.


常见错误:


CXF Service(URL, QName, WebServiceFeature[]) getPort ... is undefined 
关于题目:Service(URL, QName, WebServiceFeature[]) is undefined

网上的资料少,就这个:

原因是CXF自带的javax.xml.service 版本高过 jdk的javax.xml.service。

一个解决办法是:

在使用wsdl2java时,加入参数 -frontend jaxws21


但是重新生成 代码之后 getPort 还会有错误。

如果你用的是myeclipse 那么 尝试一下的办法:


将myeclipse JAVA EE 5 Libraries 删掉 然后再加上。就不会报错了。

myeclipse 的包加载是有顺序的,看下项目下的 .classpath 就明白了。其实我们需要的东西在CXF 包里面都有了。只是myeclipse开始的时候默认加载的是javaee.jar





CXF关于wsdl2java 生成 service class 构造器报错的解决办法
I'm marking this as "not a problem" as the generated code is correct per spec. CXF 2.3.2 is a JAX-WS 2.2 compliant implementation and thus must generate code compliant to the JAX-WS 2.2 specification which requires those constructors like that. HOWEVER, to compile them on Java 6, you will likely need to endorse the 2.2 jaxws-api jar (and likely the jaxb-api jar as well). See the 2.3 migration guide: http://cxf.apache.org/docs/23-migration-guide.html for some details about the endorsed stuff.

The alternative workaround, right now, is to delete the api jars from lib/endorsed. In that case, wsdl2java will detect that the 2.2 versions are not available/endorsed and will switch to generating 2.1 compliant code.

I also just added a new frontend (will be there for 2.3.3) to force 2.1 behavior. With 2.3.3, you'll be able to do "wsdl2java -frontend jaxws21" to tell it to use the JAX-WS 2.1 compliant frontend instead.





解决办法:



Alternative workaround you recommended works great!

"wsdl2java -frontend jaxws21" sounds better to me. I think it will be an important new feature to CXF as not many organisations may have moved past Java6 and would like to have jaxws_2.1

你可能感兴趣的:(java)