Leonel
Leonel

Reputation: 2866

JAX WS wsdl generation - how to change the service name

Server: JBoss 7.1 Java: 7 (JAX-WS version: 2.2.4-b01)

Ex1:

@Name("CustomerServices")
@Stateless
@WebService
public class CustomerServices{ ... }

Ex2:

@Name("CustomerServices")
@Stateless
@WebService(servicename="CustomerServices")
public class CustomerServices { ... }

When the JBOSS generated the wsdl files throught JAX-WS the wsdl looks like:

Ex1:

<wsdl:definitions>
...
    <wsdl:service name="CustomerServicesService">
        <wsdl:port binding="tns:CustomerServicesServiceSoapBinding"> 
            <soap:address location="<host>:<port>/<ejb-context>/CustomerServices"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

Ex2:

<wsdl:definitions>
...
    <wsdl:service name="CustomerServices">
        <wsdl:port binding="tns:CustomerServicesServiceSoapBinding"> 
            <soap:address location="<host>:<port>/<ejb-context>/CustomerServicesService/CustomerServicesService"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

So my question is, how to get this output?

<wsdl:definitions>
...
  <wsdl:service name="CustomerServices">
    <wsdl:port binding="tns:CustomerServicesServiceSoapBinding"> 
    <soap:address location="<host>:<port>/<ejb-context>/CustomerServices"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

The service name must be CustomerServices and not CustomerServicesService and the address location must be ../CustomerServices

Thanks.

Upvotes: 1

Views: 7194

Answers (1)

Pablo Lascano
Pablo Lascano

Reputation: 662

Try:

@WebContext(contextRoot = "<ejb-context>", urlPattern = "/CustomerServices")

Also you can set the portType to something else (i.e: <wsdl:portType name="MyCustomerServices"> this will be the name of your port interface when generating the client) using:

@WebService(name = "MyCustomerServices", serviceName = "CustomerServices")

Upvotes: 2

Related Questions