使用Apache CXF更改WSDL xsd:complexType名称 [英] Change WSDL xsd:complexType name with Apache CXF
问题描述
我使用Apache CXF发布Web服务,即时生成WSDL。这很好用,但是我想更改生成类型的命名约定。当服务客户端(C#)基于WSDL生成代码时,默认的xsd:complexType命名会导致类型名称以小写字母开头。
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.
以下是摘录从生成的WSDL中获取:
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>
这是导致上述WSDL片段的Java代码:
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;
}
如何更改生成的WSDL以使用类似< xs:complexType name = ProtocolItem>
?
How can I change the generated WSDL to use something like <xs:complexType name="ProtocolItem">
?
希望我没有丢失明显的注释。
Hopefully I am not missing a obvious annotation... Thanks!
编辑:谢谢!因此,有一种方法可以按类执行-我可以配置CXF命名约定吗?如果我不需要注释所有类,那就太好了。
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.
推荐答案
尝试一下:
@XmlType(name="ProtocolItem")
public class ProtocolItem {
...
}
希望这会有所帮助。
这篇关于使用Apache CXF更改WSDL xsd:complexType名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!