2013-06-04 66 views
6

我有很多端点注有@WebService(targetNamespace = "mynamespace")。每个@WebResult@WebParam具有与targetNamespace = "mynamespace"相同的定义。如何在JAX-WS Web服务中全局配置目标名称空间?

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

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

回答

2

只有把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为 Web服务。

另一方面,如果您不需要使用JAX-B定制的东西,则可以避免使用所有注释,并仅使用@WebService

其他位于JSR-181 Web Services Metadata for the JavaTM Platform

+6

当我在'@ WebResult'和在'@ WebParam'在SOAP响应所生成的XML有用于最外层XML标签的命名空间(例如'')。参数(''而不是'')也是如此。 – timomeinen

+0

有人会认为上面的例子会起作用,但不幸的是它不喜欢上面提到的tim。为什么这么简单不容易实现?必须有一种方法,不要在每个WebParam和WebResult注释中不断复制和粘贴这个名称空间。 – GreenieMeanie

相关问题