1

I am using jaxws-maven-plugin to generate Java stubs from a WSDL file using the Java API for XML Web Services (JAX-WS) specification.

I have a repo that reproduces the following issue on GitHub: https://github.com/ethanimproving/OpenAPI-Stubs/tree/jaxws (specifically in the jaxws branch).

The VoidTicketLLS2.1.0RQ.wsdl that is used to generate Java stubs refers to VoidTicketLLS2.1.0RS.xsd which refers to STL_For_ServiceProtocol.xsd which finally refers to STL_Header_v.1.2.0.xsd, which contains a simpleType called CompletionCodes:

<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>

Currently when mvn clean install is run, it is generating the following enum:

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

My main goal is to add namespace = "http://services.sabre.com/STL_Header/v120" to the @XmlType annotation so that the generated file is:

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

I read that there is an element called xmlType available in the http://java.sun.com/xml/ns/jaxb/xjc namespace that I can use in the binding.xjb file, so I've tried configuring it like this:

<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>

But JAXB is not finding that declaration.

Can anybody tell me a valid way to customize the @XmlType annotation so that I can change the name and namespace using jaxws-maven-plugin ?

Ethan Miller
  • 361
  • 2
  • 13

0 Answers0