JAX-WS / CXF 中的多个 @WebService 注释

发布于 2024-08-24 19:56:15 字数 499 浏览 1 评论 0原文

我正在尝试在 JAX-WS 中实现次要版本,如下所示:

@WebService(targetNamespace="http://mycompany.com/api/Service/v1_0")
public interface ServiceRev0 {
    public void initialMethod();
}

@WebService(targetNamespace="http://mycompany.com/api/Service/v1_1")
public interface ServiceRev1 {
    public void newMethod();
}

public class Service implements ServiceRev0, ServiceRev1 {
    ...
}

Endpoint.publish("api", new Service());

不幸的是,CXF 似乎只能“看到”第一个接口及其关联方法。是否可以做我想做的事或者我应该采取另一种方法?

I am trying to implement minor versions in JAX-WS as follows:

@WebService(targetNamespace="http://mycompany.com/api/Service/v1_0")
public interface ServiceRev0 {
    public void initialMethod();
}

@WebService(targetNamespace="http://mycompany.com/api/Service/v1_1")
public interface ServiceRev1 {
    public void newMethod();
}

public class Service implements ServiceRev0, ServiceRev1 {
    ...
}

Endpoint.publish("api", new Service());

Unfortunately, CXF only appears to 'see' the first interface and its associated methods. Is it possible to do what I want or should I take another approach?

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

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

发布评论

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

评论(3

ゞ记忆︶ㄣ 2024-08-31 19:56:15

从逻辑上看,这似乎是错误的,当您添加@WebService注释时,如果它在类上,则意味着它是一个Web服务实现,如果在接口上,则意味着定义一个Web服务接口。

您的上述定义导致两个不同的 WSDL,其中包含不同的操作,最好定义两个不同的 Web 服务接口并提供适当的实现。

It seems wrong logically, When you add @WebService annotation if its on a class it means its a webservice implementation, if on a interface it means defining a Web Service interface.

The above definition of yours lead to two different WSDL's with different operations in it, its better you define two different webservice interfaces and provide appropriate implementations.

So尛奶瓶 2024-08-31 19:56:15

嗯。这看起来很像通过 CXF 传播的致命钻石问题!我知道这已经很旧了,但我会尝试明确声明具体方法,如 这个问题,然后重试。

(我希望我对这么老的东西发表评论不是邪恶的!)

Hmmm. That looks much like the Deadly Diamond of Death problem channelled through CXF! I know this is old, but I would try explicitly declaring the concrete methods as in the second and third answer from this question, and try again.

(I hope I'm not evil for commenting on such an old item!)

无声情话 2024-08-31 19:56:15

我在使用 cxf 3 时遇到了同样的问题。
解决方案/解决方法是创建扩展需要公开的接口的第三个接口

@WebService(targetNamespace="http://mycompany.com/api/Service/v2")
public interface ServiceRev extends ServiceRev1, ServiceRev2
{
}

暴露:

public class ServiceRevImpl implements ServiceRev
{
....
}

I had a same issue using cxf 3.
Solution/workaround is to create 3rd interface that extends interfaces that need to be exposed.

@WebService(targetNamespace="http://mycompany.com/api/Service/v2")
public interface ServiceRev extends ServiceRev1, ServiceRev2
{
}

Expose:

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