【问题标题】:@XmlTransient ignored in generating WSDL - Axis2 WS@XmlTransient 在生成 WSDL 时被忽略 - Axis2 WS
【发布时间】:2012-10-15 15:51:00
【问题描述】:

我有课

public class Calculator {
    public Test getTest(){
        return new Test();
    }
}

我想公开为 Web 服务。测试定义是:

public class Test {
    private Test2[] tests;
    @XmlTransient
    public Test2[] getTests() {
        return tests;
    }
    public void setTests(Test2[] tests) {
        this.tests = tests;
    }
}

现在,在 Test2[] 测试中添加 @XmlTransient 注释,我希望它不会在生成的 WSDL 中列出(我使用的是 Eclipse,所以右键单击计算器 > Web 服务 > 生成 Web 服务),但我错了:

...
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="...">
<xs:complexType name="Test">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="tests" nillable="true" type="ax21:Test2"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Test2">
<xs:sequence/>
</xs:complexType>
</xs:schema>
...
</wsdl:types>
...

如您所见,tests 仍然存在于 WSDL(第 5 行)中。 如果有用,我正在使用 Axis2,Eclipse Indigo。

【问题讨论】:

    标签: eclipse web-services wsdl axis2 xmltransient


    【解决方案1】:

    这仍然是个问题,但我找到了解决方法。我添加到我的 services.xml 中:

        <parameter name="beanPropertyRules">
            <bean class="package.Test" excludeProperties="tests" />
        </parameter>
    

    即:

     <bean class="package.Object" excludeProperties="propertyToExcludeFromWSDL" />
    

    这行得通。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-23
      • 1970-01-01
      • 1970-01-01
      • 2017-07-07
      • 2015-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多