使用xjc和自定义绑定文件注入注释

时间:2015-07-31 10:51:19

标签: java jaxb wsdl xjc xjb

好吧,我已经将这个外部(和旧的)WSDL结构如下:

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:tns="...custom namespace..."
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    targetNamespace="...custom namespace..."
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="...custom namespace...">
            <s:element name="...">
            </s:element>
            <s:element name="...">
            </s:element>
            <s:complexType name="CustomClassName">
            ...

我使用xjc从这个WSDL创建Java类。

我在此WSDL中使用的请求以 CustomClassName 开头的纯XML响应,但此类未使用 XMLRootElement 进行注释。

当我手动将此注释添加到此类时,我的代码工作正常。

但我想在调用xjc和a.t.m时使用自定义绑定文件添加注释。我无法让这个工作。我当前的自定义绑定文件如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings 
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:s="http://www.w3.org/2001/XMLSchema" 
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:annox="http://annox.dev.java.net"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    jaxb:extensionBindingPrefixes="xjc annox" version="2.1">

    <jaxb:bindings schemaLocation="...wsdl filename..." node="//s:schema">
        <jaxb:bindings node="s:complexType[@name='CustomClassName']">
            <annox:annotate>
                <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" />
            </annox:annotate>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

(我已经尝试了不同的语法,但我仍未对该类进行注释。)

我的错误在哪儿?

0 个答案:

没有答案