如何使用 jaxws-maven-plugin 自定义 @XmlType

问题描述 投票:0回答:0

我正在使用

jaxws-maven-plugin
使用 Java API for XML Web Services (JAX-WS) 规范从 WSDL 文件生成 Java 存根。

我有一个在 GitHub 上重现以下问题的 repo:https://github.com/ethanimproving/OpenAPI-Stubs/tree/jaxws(特别是在 jaxws 分支中)。

用于生成Java存根的

VoidTicketLLS2.1.0RQ.wsdl
引用
VoidTicketLLS2.1.0RS.xsd
引用
STL_For_ServiceProtocol.xsd
最终引用
STL_Header_v.1.2.0.xsd
,其中包含一个名为
CompletionCodes
的simpleType:

<xsd:simpleType name="CompletionCodes">
  <xsd:restriction base="xsd:token">
    <xsd:enumeration value="Complete"/>
    <xsd:enumeration value="Incomplete"/>
    <xsd:enumeration value="NotProcessed"/>
    <xsd:enumeration value="Unknown"/>
  </xsd:restriction>
</xsd:simpleType>

目前当

mvn clean install
运行时,它正在生成以下枚举:

@XmlType( name = "CompletionCodes" )  
@XmlEnum  
public enum CompletionCodes

我的主要目标是在

namespace = "http://services.sabre.com/STL_Header/v120"
注解中加上
@XmlType
,这样生成的文件是:

@XmlType(
    name = "VoidCompletionCodes",
    namespace = "http://services.sabre.com/STL_Header/v120"
)
@XmlEnum
public enum CompletionCodes

我读到在

http://java.sun.com/xml/ns/jaxb/xjc
命名空间中有一个名为 xmlType 的元素可用,我可以在
binding.xjb
文件中使用它,所以我已经尝试像这样配置它:

<jaxb:bindings version="1.0"  
              xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"  
              xmlns:xs="http://www.w3.org/2001/XMLSchema"  
              jaxb:extensionBindingPrefixes="xjc"  
              xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">  
  
  <jaxb:bindings schemaLocation="STL_Header_v.1.2.0.xsd"  
                 xmlns="http://services.sabre.com/STL_Header/v120">  
    <jaxb:schemaBindings>  
      <jaxb:package name="com.sabre.sws.header"/>  
    </jaxb:schemaBindings>  
    <jaxb:bindings node="//xs:simpleType[@name='CompletionCodes']">  
      <!-- xmlType is supposed to be a valid element available in the http://java.sun.com/xml/ns/jaxb/xjc namespace, but  
        JAXB is not finding that declaration. End goal: generate jakarta.xml.bind.annotation.XmlType on CompletionCodes  -->      <xjc:xmlType name="VoidCompletionCodes" namespace="http://services.sabre.com/STL_Header/v120" />  
    </jaxb:bindings>  
  </jaxb:bindings>  
</jaxb:bindings>

但是 JAXB 没有找到那个声明。

任何人都可以告诉我自定义

@XmlType
注释的有效方法,以便我可以使用
jaxws-maven-plugin
更改名称和命名空间吗?

jax-ws xmltype jax-ws-customization jaxws-maven-plugin
© www.soinside.com 2019 - 2024. All rights reserved.