如何防止 JAXBElement在 CXF Web 服务客户端中生成?
我正在尝试使用 CXF 创建一个 Web 服务客户端来使用 WCF Web 服务。 当我使用 wsdl2java 时,它生成具有 JAXBElement 类型而不是 String 的对象。
我读到有关使用 jaxb Bindings.xml 文件设置generateElementProperty =“false”来尝试解决问题,但我正在使用的Web服务包含7个导入的模式。
如何在所有七个架构上指定 generateElementProperty="false"
,或者有没有办法将其应用于所有架构?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须创建一个绑定文件,如下所示,这将在全局范围内应用并将其用作
wsdl2java - b“绑定.txt”“wsdl”
You have to create a binding file as below, this will get applied globally and use it as
wsdl2java - b "bindings.txt" "wsdl"
请注意,在我的例子中,我必须在 jaxb 绑定文件中使用 来摆脱
@Endpoint 中的
JAXBElement
请求和响应包装器:Note that in my case I had to use
<xjc:simple
in my jaxb binding file to get rid of theJAXBElement
request and response wrappers in the@Endpoint
:如果我们使用与 Jakarta EE 兼容的 CXF 版本,我们应该将语法更改为:
If we are using a CXF version compatible with Jakarta EE, we should change the syntax to: