问题描述
拥有JAXB-RI和CXF。 WSDL首先。我想要一个生成的类来实现 Serializable
。我现在有以下绑定xml,它可以工作(SEI类名称被更改)
Having JAXB-RI and CXF. WSDL first. I want a generated class of mine to implement Serializable
. I now have the following binding xml, which works (the SEI class name gets changed)
<jaxws:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
<bindings node="wsdl:definitions/wsdl:portType[@name='Foo']">
<!-- change the generated SEI class -->
<class name="IFooService" />
</bindings>
</jaxws:bindings>
不,在这种情况下,我应该添加的位置和内容。我试过了:
No, in this context, where and what should I add. I tried:
<xsd:annotation>
<xsd:appinfo>
<jaxb:globalBindings>
<xjc:serializable uid="12343" />
</jaxb:globalBindings>
</xsd:appinfo>
</xsd:annotation>
和
<jxb:globalBindings>
<jxb:serializable/>
</jxb:globalBindings>
< bindings>
标记 - 未添加 Serializable
,或者根本不生成类(没有任何错误)。
both inside and outside the <bindings>
tag - either Serializable
is not added, or classes are not generated at all (without any error).
另请参见
那么,究竟是怎么做的
推荐答案
我做到了以两种方式工作:
I made it work in two ways:
-
使用第二个绑定文件,它只是JAXB,就像Pascal在他的回答
通过指定处理整个命名空间的另一个< bindings>
标记:
By specifying another <bindings>
tag that handles the whole namespace:
<bindings
node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://www.yoursite.com/services/mynamespace']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:serializable />
</jxb:globalBindings>
</bindings>
这篇关于JAXB使用JAX-WS绑定生成可序列化的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!