How to configure global target namespace in JAX-WS web services?

I have many endpoints annotated with @WebService(targetNamespace = "mynamespace") . Each @WebResult and @WebParam have the same definition of targetNamespace = "mynamespace" .

Is there a way to configure JAX-WS (Metro implementation) to use "mynamespace" as targetNamespace by default?

I would like to use annotations without any attributes and get rid of duplicate ads, just like a configuration convention.

+6
source share
1 answer

Place only targetNamespace in the service endpoint interface or bean service implementation.

 /** * 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) { ... } }; 

If @WebResult or @WebParam do not have targetNamespace , the default is targetNamespace for the web service.

In the other hand, you can avoid all annotations and use only @WebService if you don't need something custom with JAX-B.

Learn more in the JSR-181 Web Services Metadata for the JavaTM Platform

+2
source

Source: https://habr.com/ru/post/946493/


All Articles