gpt4 book ai didi

jax-ws - 如何在 JAX-WS Web 服务中全局配置目标命名空间?

转载 作者:行者123 更新时间:2023-12-03 10:13:43 27 4
gpt4 key购买 nike

我有很多用 @WebService(targetNamespace = "mynamespace") 注释的端点.每@WebResult@WebParamtargetNamespace = "mynamespace" 的定义相同.

有没有办法配置 JAX-WS(Metro 实现)以使用 "mynamespace"默认为targetNamespace?

我想使用没有任何属性的注释并摆脱重复的声明,就像约定优于配置一样。

最佳答案

只放targetNamespace在服务端点接口(interface)或服务实现中
bean 。

/**
* Annotated Implementation Object
*/
@WebService(
name = "CustomerService",
targetNamespace = "http://org.company.services"
)
public class CustomerService {
@WebMethod
@WebResult(name="CustomerRecord")
public CustomerRecord locateCustomer(
@WebParam(name="FirstName") String firstName,
@WebParam(name="LastName") String lastName,
@WebParam(name="Address") USAddress addr) {
...
}
};

如果 @WebResult@WebParam没有 targetNamespace , 默认为 targetNamespace为了
网络服务。

另一方面,您可以避免使用所有注释,而只使用 @WebService如果您不需要 JAX-B 的自定义内容。

JSR-181 Web Services Metadata for the JavaTM Platform 中查看更多信息

关于jax-ws - 如何在 JAX-WS Web 服务中全局配置目标命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16915962/

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