Search code examples
javawsimport

wsimport generates faulty code


I use wsimport to generate my java stub files. For this, I use an ant build file in Eclipse:

<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath>
        <fileset dir="../lib">
            <include name="jaxws-tools.jar" />
        </fileset>
    </classpath>
</taskdef>

<target name="generate">
    <wsimport wsdl="../wsdl/Knowledgebase.wsdl"
              destdir="../bin"
              sourcedestdir="../gen"
              keep="true"
              xendorsed="true">
    </wsimport>
</target>

The task runs without any errors. It creates different java-files, also Knowledgebase.java and KnowledgebasePort.java. In der Knowledgebase.java, there are these constructors:

public Knowledgebase(WebServiceFeature... features) {
    super(__getWsdlLocation(), KNOWLEDGEBASE_QNAME, features);
}

For them I get an error "The constructor Service(...) is undefined". I imported the current jax-ws jar files. Is my generation process broken, do I use the wrong jars or where is the error?


Solution

  • The Service object is provided by the Java EE SDK. It added a new constructor between Java EE 5 and Java EE 6. It would seem the wsimport you're using is from a Java EE 6 JDK and the compiler is using a Java EE 5 SDK?