CXF 客户端复制目标命名空间

发布于 2024-08-28 07:36:15 字数 1214 浏览 5 评论 0原文

我在同一台服务器上托管一个由 wsdl2java 生成的 Web 服务和 Web 应用程序。我可以通过 SoapUI 很好地联系该服务,并且在发布到实时服务器时它会返回一个命名空间声明,但是当我在本地工作并使用 SoapUI 时,它会生成两个 xlmns="" 实例,而不是我的 xml 中的单个实例。我在下面复制了一个示例 xml 文件:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>
<SendResponse xmlns="http://myendpoint.org/service" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Receipt>
<MyReceipt xmlns:ns3="http://myendpoint.org/service" xmlns="" xmlns="" xmlns:ns6="http://myapp.myserver.net/myservicegroup/myservice/V01" receiptVersion="V01">
  <ReceiptHeader>
    <ReceiptTimestamp>2010-04-13T08:27:03.036-04:00</ReceiptTimestamp>
  </ReceiptHeader>
  <TransmissionReceipt>
    <TransmissionID>testuser</TransmissionID>
    <TransmissionTimestamp>2010-04-13T08:27:03.036-04:00</TransmissionTimestamp>
  </TransmissionReceipt>
</MyReceipt></Receipt></SendResponse></soap:Body></soap:Envelope>

因此,当它解组时,当我使用我的 web 应用程序作为 web 服务客户端时,它会严重失败。为什么 CXF 添加第二个命名空间?我一直观察调试直到返回,它在 Web 服务方面看起来 100% 完美,根本没有重复的名称空间。直到 xml 返回到客户端时才会发生这种情况。

I am hosting a webservice and a webapp on the same server, generated from wsdl2java. I can contact the service just fine through SoapUI and it returns a single namespace declaration when posted to the live server, but when I am working locally and use SoapUI it generates two instances of xlmns="" instead of a single one in my xml. I have copied below an example xml file:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>
<SendResponse xmlns="http://myendpoint.org/service" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Receipt>
<MyReceipt xmlns:ns3="http://myendpoint.org/service" xmlns="" xmlns="" xmlns:ns6="http://myapp.myserver.net/myservicegroup/myservice/V01" receiptVersion="V01">
  <ReceiptHeader>
    <ReceiptTimestamp>2010-04-13T08:27:03.036-04:00</ReceiptTimestamp>
  </ReceiptHeader>
  <TransmissionReceipt>
    <TransmissionID>testuser</TransmissionID>
    <TransmissionTimestamp>2010-04-13T08:27:03.036-04:00</TransmissionTimestamp>
  </TransmissionReceipt>
</MyReceipt></Receipt></SendResponse></soap:Body></soap:Envelope>

So when it unmarshalls, it fails badly when I use my webapp as a webservice client. Why is CXF adding a second namespace? I watched the debug all the way through until the return and it looked 100% perfect on the webservice side, no duplicate name space at all. It does not happen until the return of the xml to the client side.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最冷一天 2024-09-04 07:36:15

在 XML 中,每个元素的属性都是唯一的,因此如果发生这种情况,则可能是一个错误,您应该将其报告为错误。我以前使用过 CXF,它是一个很棒的库,但不幸的是它并不完美。我不得不尝试各种版本,升级到不稳定的版本来解决我遇到的错误。

W3C XML 规范

属性名称不得在同一开始标记或空元素标记中出现多次。

In XML, attributes are unique to each element, so if this occurs then it is probably a bug and you should report it as such. I've worked with CXF before and it's a great library, but it's unfortunately not perfect. I had to mess around with various versions, upgrading to an unstable one to get around the bugs I encountered.

W3C XML Spec

An attribute name MUST NOT appear more than once in the same start-tag or empty-element tag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文