gpt4 book ai didi

web-services - jax-ws 关于端点接口(interface)

转载 作者:行者123 更新时间:2023-12-04 01:44:48 25 4
gpt4 key购买 nike

定义了一个带有注解 的 Java 接口(interface)@WebService
编译了运行良好的代码

例子:

@WebService
public interface HelloWorldIfc{

现在我尝试将端点接口(interface)定义为
 @WebService (endpointInterface = "com.ws.HelloWorldIfc")
public interface HelloWorldIfc{

这也编译得很好

那么-我应该在接口(interface)上还是在实现类上定义端点接口(interface)?
这个属性有什么用吗?它的目的是什么?
如果我不定义它会发生什么 - 我会失去什么?
谢谢,
萨蒂什

最佳答案

The JAX-WS Specification在第 3.3 节,第 30 页中阐明了这一点:

您可以使用 endpointInterface属性来分隔实现类和接口(interface)。基本上,这决定了将映射到您的 wsdl:portType 的内容。当您部署服务和 wsdl:definition生成。

如果不定义 endpointInterface注释类的所有公共(public)方法都将映射到 wsdl:operation (只要您不使用 @WebMethod 注释影响此行为)。

如果您确实定义了 endpointInterface ,它必须指向带注释的类实现的某种类型(或者,如您的问题所示,它本身)。然后,这种类型的公共(public)方法用于映射 wsdl:portType ,而不是注释类的方法。

总结一下:endpointInterface的定义仅当您使用 @WebService 时才有意义在实现类上,并希望根据它实现的接口(interface)生成 WSDL。在您当前使用界面com.ws.HelloWorldIfc上的注释的设置中,真的没有任何区别。因此,您只需跳过它就不会失去任何东西。如果您希望实现类提供不应进入生成的 WSDL 的公共(public)方法,则该注释很有用。

关于web-services - jax-ws 关于端点接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14320609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com