Comic Sans MS Lover
Comic Sans MS Lover

Reputation: 1729

Why is wsimport generating "incomplete" classes?

First I'll give you an overview of the situation. I will not list every single class of my project, only the ones I think that are relevant. If you feel like something is missing, please let me know and I'll add.

2 Projects:

WS

Client

5 Classes (they belong to WS):

Main.java

User.java

ModuleMain

ModuleSecondary.java

ModuleEmergency.java

The User class has the following fields:

String username

String password

ModuleMain main

ModuleSecondary secondary

ModuleEmergency emergency

Every "Module" class has 3 boolean fields, which are permissions to access the module. they are:

boolean canMonitor

boolean canAdd

boolean canRemove

This is the WS class. This class is the one that publishes the endpoint:

        Endpoint endpoint = Endpoint.create(new UserWs());
        //UserWs would be a WebService.
        SSLContext ssl = SSLContext.getInstance("SSLv3");

        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        KeyStore jks = KeyStore.getInstance("PKCS12");

        jks.load(new FileInputStream(path), pwField.getText().toCharArray());

        kmf.init(jks, pwField.getText().toCharArray());
        KeyManager[] keyManagers = kmf.getKeyManagers();

        tmf.init(jks);

        TrustManager[] trustManagers = tmf.getTrustManagers();

        ssl.init(keyManagers, trustManagers, new SecureRandom());

        HttpsConfigurator configurator = new HttpsConfigurator(ssl);

        server = HttpsServer.create(new InetSocketAddress("localhost", 443), 443);
        server.setHttpsConfigurator(configurator);

        HttpContext context = server.createContext("/ws");
        server.start();

        endpoint.publish(context);

After I run the WebService, I use the wsimport tool to get the classes into the Clientproject.

wsimport -verbose -Xdebug -keep -p ws.api https://localhost:443/ws?wsdl

Those are some of the classes I get:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "user", propOrder = {
"moduleMain",
"moduleSecondary",
"moduleEmergency",
"sessionKey",
"username"
})
public class User {

protected ModuleMain main;
protected ModuleSecondary secondary;
protected ModuleEmergency emergency;
protected String username;

//...getters and setters for those fields...//
}

As you can see, the password field is left off. But this really isn't the problem, the problem are the generated Module classes:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "main")
public class ModuleMain {


}

And that's it. The other Module classes are the same thing. They don't have any methods so I have no access to the permission fields. I can't figure what is the problem, probably it's the WSDL but I have no idea how to fix this.

Any help is greatly appreciated. Sorry for grammar mistakes.

Upvotes: 0

Views: 2133

Answers (1)

Glen Mazza
Glen Mazza

Reputation: 788

The problem can be either of two things -- (A) that the WSDL being generated from your Java-first web service is not capturing all the desired fields, or (B) that the subsequent wsdl-to-java wsimport process is not reading the WSDL correctly. Have you determined which it is by looking at the WSDL? If it's A, you should be showing us the generated WSDL and asking why important fields are missing (and not show us the artifacts subsequently generated by the WSDL--that no longer matters as the problem isn't there) If it's B, show us the WSDL and forget about what you did to generate it and then ask why the fields are missing during the wsimport process. By not providing the WSDL, we can't determine easily whether the problem is in (A) or (B). Note articles 2 and 3 on my blog may be of help for you.

Upvotes: 1

Related Questions