Microsoft Web 服务和 CXF 客户端:JAXB 无法理解“s:schema”
我有普通的 Microsoft webservice 和最新版本的普通 CXF,带有 Java/JDK 1.6、Eclipse 等。当我运行 wsdl2java 时,JAXB 部分抛出错误 “由 JAXB 抛出:未定义的元素声明 's:schema'”
导致它的 WSDL 部分如下所示:
<s:element name="GetDepartmentsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDepartmentsResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
我可以简单地删除
无处不在并保留
?它看起来像是 Java<->Microsoft Web 服务互操作性的常见障碍。但我找不到 CXF 的任何解决方法。
I have ordinary Microsoft webservice and normal CXF of latest version with Java/JDK 1.6, Eclipse etc. When I am running wsdl2java, the JAXB part throws an error
"Thrown by JAXB: undefined element declaration 's:schema' "
The part of WSDL which causes it looks like:
<s:element name="GetDepartmentsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDepartmentsResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema" />
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
Can I simply remove<s:element ref="s:schema" />
everywhere and keep <s:any/>
? It looks like common obstacle for Java<->Microsoft webservices interoperability. But I can not find any workaround for CXF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常您可以删除架构引用。您可能需要将
更改为
或类似内容,以确保都有空间容纳schema 元素及其后面的任何内容。Usually you can remove the schema ref. You may need to change the
<s:any>
to<s:any maxOccurs="2">
or similar to make sure there is room for both the schema element and anything that follows it.就我个人而言,我不建议修改您的 WSDL。 WSDL 定义了服务强加的契约,实际上您不应该在客户端中更改它。如果您查看此处的答案https://stackoverflow.com/a/19126124/1732319,它描述了您如何可以让
wsdl2java
正确处理s:schema
。我在项目中使用 CXF codegen maven 插件,并具有以下配置:
customization.xjb
取自我上面引用的答案。Personally, I wouldn't suggest modifying your WSDL. The WSDL is defining the contract imposed by the service, and it's not really something you should be changing in your client. If you take a look at the answer here https://stackoverflow.com/a/19126124/1732319 it describes how you can get
wsdl2java
to deal withs:schema
properly.I'm using the CXF codegen maven plugin in my project and have the following configuration:
customisation.xjb
is taken from the answer I references above.