Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 222
Matthias Wuttke Avatar asked Mar 22 '23 14:03

Matthias Wuttke


1 Answers

Try this:

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

Hope this helps.

like image 64
Farzad Fallah Avatar answered Mar 31 '23 15:03

Farzad Fallah