简体   繁体   中英

Change WSDL xsd:complexType name with Apache CXF

I use Apache CXF to publish a webservice, generating the WSDL "on-the-fly". This works great, but I would like to change the naming convention of the generated types. As the service clients (C#) generate code based on the WSDL, the default xsd:complexType naming results in type names starting with lower-case letters.

Here is an excerpt from the generated WSDL:

<xs:complexType name="protocolItem">
<xs:sequence>
  <xs:element minOccurs="0" name="data" type="tns:protocolItemData"/>
  <xs:element maxOccurs="unbounded" minOccurs="0" name="elements" nillable="true" type="tns:protocolElement"/>
  <xs:element minOccurs="0" name="meta" type="tns:protocolItemMeta"/>
</xs:sequence>
</xs:complexType>

This is the Java code that results in the above WSDL fragment:

@RooJavaBean
public class ProtocolItem {

    private ProtocolItemData data;
    private ProtocolItemMeta meta;
    private List<ProtocolElement> elements;

}

How can I change the generated WSDL to use something like <xs:complexType name="ProtocolItem"> ?

Hopefully I am not missing a obvious annotation... Thanks!

EDIT : thanks for the first answer! So there is a way to do this "per class" - can I configure the CXF naming conventions? Would be nice if I did not need to annotate all classes.

Try this:

@XmlType(name="ProtocolItem")
public class ProtocolItem {
   ...
}

Hope this helps.

Using the Aegis data binding instead of the JAXB data binding with Apache CXF helped: This changed the naming convention. Unfortunately, I realised this after having added all @XmlType annotations, so I removed them again...

I stumbled over Aegis when searching for a solution for collections/arrays - they are not wrapped with JAXB, but with Aegis, which is required for proper client code generation (typed collections instead of arrays).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM