是否可以使用CXF生成可序列化的类? [英] Is it possible to generate serializable classes with CXF?
本文介绍了是否可以使用CXF生成可序列化的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Apache CXF从WSDL文件生成类,但是它们没有实现将对象放入JMS队列所需的Serializable。
I'm using Apache CXF to generate classes from a WSDL file but they don't implement Serializable which is needed to put an object into a JMS queue. Is it possible to do this or do I have to convert the generated classes into my own and send those?
推荐答案
我发现了解决我自己的问题,所以这就是将来是否有人需要的东西:
I found the solution myself so here it is if anybody needs it in the future:
1。将此插件添加到pom.xml
1. add this plugin to pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlRoot>${basedir}/src/main/resources</wsdlRoot>
<includes>
<include>*Service.wsdl</include>
</includes>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/your_wsdl.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-impl</extraarg>
<extraarg>-server</extraarg>
<extraarg>-verbose</extraarg>
<extraarg>-validate</extraarg>
</extraargs>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/binding.xml</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
2。编写自定义绑定(binding.xml)
2. write a custom binding (binding.xml)
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings wsdlLocation="Send.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://wsdl/SendService.wsdl']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:serializable uid="11082011"/>
</jxb:globalBindings>
</jaxws:bindings>
</jaxws:bindings>
3。运行 mvn generate-sources
3. run 'mvn generate-sources'
这篇关于是否可以使用CXF生成可序列化的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文