为cxf生成的类添加前缀

发布于 2024-12-27 02:07:27 字数 50 浏览 5 评论 0原文

我使用 CXF 从 wsdl 生成 Java 类。是否可以为所有生成的类名称分配前缀?

I use CXF to generate Java classes form wsdl. Is it possible to assign a prefix to all generated classes names?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹苦笑 2025-01-03 02:07:27

wsdl2java 工具有一个 -b 选项:

-b |绑定名称 |指定 JAXWS 或 JAXB 绑定文件或 XMLBeans 上下文文件。使用多个 -b 标志来指定多个条目。

您提供的绑定文件需要具有以下内容:

<jxb:bindings version="1.0"
  xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
  jxb:extensionBindingPrefixes="xjc">

    <jxb:bindings schemaLocation="../xsd/schema.xsd" node="/xs:schema">
        <jxb:schemaBindings>
            <jxb:nameXmlTransform>
                <jxb:typeName prefix="Foo"/>
                <jxb:anonymousTypeName prefix="Foo"/>
                <jxb:elementName prefix="Foo"/>
            </jxb:nameXmlTransform>
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

这会将 Foo 前缀添加到为类型、匿名类型和元素生成的类中。请注意,schemaLocation 属性必须指向实际架构。

The wsdl2java tool has an -b option:

-b | binding-name | Specifies JAXWS or JAXB binding files or XMLBeans context files. Use multiple -b flags to specify multiple entries.

The binding file you provide needs to have the following contents:

<jxb:bindings version="1.0"
  xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
  jxb:extensionBindingPrefixes="xjc">

    <jxb:bindings schemaLocation="../xsd/schema.xsd" node="/xs:schema">
        <jxb:schemaBindings>
            <jxb:nameXmlTransform>
                <jxb:typeName prefix="Foo"/>
                <jxb:anonymousTypeName prefix="Foo"/>
                <jxb:elementName prefix="Foo"/>
            </jxb:nameXmlTransform>
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

This adds Foo prefix to classes generated for types, anonymous types and elements. Note that the schemaLocation attribute must point to the actual schema.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文