eclipse-ee4j / metro-jax-ws

metro-jax-ws
https://eclipse-ee4j.github.io/metro-jax-ws/
BSD 3-Clause "New" or "Revised" License
72 stars 40 forks source link

WsImport should provide a one-arg constructor in the generated WebServiceClient, starting from JAX-WS 2.0 #549

Open Tomas-Kraus opened 2 years ago

Tomas-Kraus commented 2 years ago

At the moment, a one-arg constructor with type java.net.URL is only generated for JAX-WS 2.2, when indicating target=2.2 (default) to wsimport. It should also be generated starting from target=2.0, as it uses this constructor : [Service(URL wsdlDocumentLocation, QName serviceName)](http://docs.oracle.com/javase/6/docs/api/javax/xml/ws/Service.html#Service(java.net.URL, javax.xml.namespace.QName)) , compatible with JAX-WS 2.0

I identified the problem in this source file "com.sun.tools.ws.processor.generator.ServiceGenerator" - see git-repo

I think it should be modified like this :

// Generating constructor
        // for e.g:  public ExampleService(URL wsdlLocation)
        if (options.target.isLaterThan(Options.Target.V2_0)) {
            JMethod constructor3 = cls.constructor(JMod.PUBLIC);
            constructor3.param(URL.class, "wsdlLocation");
            String constructor3Str = String.format("super(wsdlLocation, %s);", serviceName);
            constructor3.body().directStatement(constructor3Str);
        }

It would be simpler to use this constructor than using this method : https://metro.java.net/guide/ch02.html#bindingprovider.endpoint_address_property

Environment

Maven 3.0 + jaxws-maven-plugin 2.3 + jaxws-tools 2.2.8 + jdk 6u41

Affected Versions

[2.2.10]

Source: https://github.com/javaee/metro-jax-ws/issues/1159 Author: glassfishrobot