简体   繁体   中英

wsimport generating empty classes (pojos) from a wsdl

Environment: NetBeans 7.1.2 glassfish 3.1.2

I've written a web service whose methods return pojos. But when I create a WebService reference in the IDE (or manually do it with wsimport), the generated classes for the pojos are empty. The following very simple web service demonstrates the problem.

The Web Service class

package snhd.dx;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class ReturnPojo {

    @WebMethod
    public Pojo getPojo() {
        return new Pojo();
    }
}

The pojo it returns

package snhd.dx;

public class Pojo {

    public final static int iPojo = 1;

    public String getText() {
        return "POJO";
    }    
}

When I create a web service reference, I get the following for the generated class:

package snhd.dx;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for pojo complex type.
* 
* <p>The following schema fragment specifies the expected content contained within this class.
* 
* <pre>
* &lt;complexType name="pojo">
*   &lt;complexContent>
*     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
*       &lt;sequence>
*       &lt;/sequence>
*     &lt;/restriction>
*   &lt;/complexContent>
* &lt;/complexType>
* </pre>
* 
* 
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "pojo")
public class Pojo {


}

What do I need to do so that the generated version of Pojo contains the correct information?

need you create a POJO with getter's and setter's methods and using into main class. I hope help you.

You need to annotate your POJO class to specify that iPojo needs to be included in the schema, I think you also need to create a constructor with no-args

It would also help us help you if you give us the WSDL content

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM