加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

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

发布时间:2020-12-14 18:37:02 所属栏目:资源 来源:网络整理
导读:我有很多用@WebService(targetNamespace =“mynamespace”)注释的端点.每个@WebResult和@WebParam都有相同的targetNamespace =“mynamespace”定义. 有没有办法将JAX-WS(Metro实现)配置为默认使用“mynamespace”作为targetNamespace? 我想使用没有任何属性
我有很多用@WebService(targetNamespace =“mynamespace”)注释的端点.每个@WebResult和@WebParam都有相同的targetNamespace =“mynamespace”定义.

有没有办法将JAX-WS(Metro实现)配置为默认使用“mynamespace”作为targetNamespace?

我想使用没有任何属性的注释,并删除重复的声明,就像约定配置.

解决方法

仅将targetNamespace放在服务端点接口或服务实现中
豆.
/**
* 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 for
Web服务.

另一方面,如果您不需要使用JAX-B进行自定义,则可以避免使用所有注释并仅使用@WebService.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读