【问题标题】:CXF: Implement multiple ports on same soap:adress?CXF:在同一个soap上实现多个端口:地址?
【发布时间】:2013-12-30 18:51:47
【问题描述】:

我们从客户那里得到一个 WSDL,要求我们在我们这边实现服务。

WSDL 包含 3 个端口绑定,具有不同的名称和绑定,但相同的 <soap:adress> --- 像这样:

<port name="Name1" binding="tns:Binding1">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
<port name="Name2" binding="tns:Binding2">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>
<port name="Name3" binding="tns:Binding3">
    <soap:address location="http://localhost/Service/ServicePort" />
</port>

这样的 WSDL 可以用 CXF 实现吗?

当我运行 wsdl2java 时,CXF 会生成 3 个 java 接口。

我首先尝试了一个实现类,比如

class MyServiceClass implements Interface1, Interface2, Interface3 {...}

但是当我部署它并使用 SoapUI 检查时,出于某种原因, 它只会暴露Interface1的端口绑定, 并且似乎忽略了另外两个。 为什么?

然后我尝试实现 3 个不同的 ServiceClass(每个都实现一个接口), 然后将多个具有相同address 属性的&lt;jaxws:endpoint&gt; 放入cxf-config.xml

然后我得到部署错误:

RuntimeException: Soap 1.1 endpoint already registered on address /Address

任何提示,如何在 CXF 中实现这样的 WSDL? 有可能吗?

【问题讨论】:

标签: soap wsdl jax-ws cxf wsdl2java


【解决方案1】:
      But when I deployed it and checked with SoapUI, for some reason, it would only expose Port-binding for Interface1, and seemed to ignore the 2 other ones. Why?

如果你会看到你的实现类,你会发现这个注解,

@WebService(endpointInterface = "yourPackageName.Interface1")

这仅指您的 interface1。这就是为什么在部署它时忽略其余 2 接口实现。

因此,您必须按照您的解释在不同的实现类中分别实现这 3 个接口。因为每个实现类只允许有一个endpointInterface。

Is such WSDL possible to implement with CXF?

是的,有可能。

在您的端点发布者类中部署期间,您需要将这3个接口实现类对象包装在一个对象中并为单个端点发布。

我仍然不清楚如何做到这一点,稍后会更新答案。

几个有用的链接:要求相同,但有点混乱。

http://cxf.547215.n5.nabble.com/Deploying-multiple-endpoints-ports-for-a-service-td569470.html

还阅读了有关 JavaBeans 端点实现的信息,我认为在这种情况下,它会比这更容易。

【讨论】:

  • 感谢您的意见!期待您的更新:) --- 谷歌搜索这方面的详细信息并不容易......
  • 实际上,我已经在我的系统中为这个需求准备了一个场景,仍然在 oracle doc 中搜索类、库等来实现这一点。顺便说一句,很好。
  • 我确实在这里找到了提示:cxf.547215.n5.nabble.com/…(丹尼尔·库尔普在页面中间的评论)。我在 cxf-servlet.xml 中添加了属性“allow-multiplex-endpoint”,实际上消除了 url/port-conflict 错误。但是行为仍然不正确,只有一个接口被暴露。实现和配置 AbstractEndpointSelectionInterceptor 的附加步骤,我无法从他链接到的代码示例中弄清楚。
猜你喜欢
  • 1970-01-01
  • 2014-11-23
  • 1970-01-01
  • 2017-05-31
  • 1970-01-01
  • 1970-01-01
  • 2021-10-14
  • 2014-01-24
  • 2018-09-04
相关资源
最近更新 更多