我想在CXF Codegen上添加@XmlRoot批注

我想在CXF Codegen上添加@XmlRoot批注,第1张

我想在CXF Codegen上添加@XmlRoot批注

我找到了解决方案。这很棘手,因为:

  1. 必须处理WSDL中内联的XSD。(技巧是schemaLocation =“ CP_Ablakido_1.wsdl#types1”。它告诉JAXB使用WSDL文件中的节点。)
  2. 必须配置CXF以使用XJC插件(annox)。

必须将以下片段添加到POM.XML:

<wsdlOption>    <wsdl>${basedir}/src/main/resources/wsdl/CP_Ablakido_1.wsdl</wsdl>    <bindingFiles>        <bindingFile>${basedir}/src/main/resources/wsdl/CP_Ablakido_1.xjb</bindingFile>     </bindingFiles>    <extraargs><extraarg>-xjc-Xannotate</extraarg></extraargs></wsdlOption>

和依赖项必须添加到插件

<dependency>    <groupId>org.jvnet.jaxb2_commons</groupId>    <artifactId>jaxb2-basics-annotate</artifactId>    <version>0.6.0</version></dependency><dependency>    <groupId>org.apache.cxf.xjcplugins</groupId>    <artifactId>cxf-xjc-ts</artifactId>    <version>3.0.5</version></dependency>

XJB文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><jaxb:bindings version="2.0"     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"    jaxb:extensionBindingPrefixes="annox xjc"    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"     xmlns:xs="http://www.w3.org/2001/XMLSchema"    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"    xmlns:annox="http://annox.dev.java.net"    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance">  <jaxb:bindings schemaLocation="CP_Ablakido_1.wsdl#types1" node="/xs:schema">        <jaxb:bindings node="//xs:complexType[@name='InputMapping1']"> <annox:annotate target="class">     <annox:annotate annox: name="GetList_11"/>          </annox:annotate>      </jaxb:bindings>          <jaxb:bindings node="//xs:complexType[@name='OutputMapping1']"> <annox:annotate target="class">     <annox:annotate annox: name="GetList_11Response"/>          </annox:annotate>      </jaxb:bindings>   </jaxb:bindings></jaxb:bindings>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5501984.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存