1
爲什麼不會wsimport
保留我的模型類的toString()
方法? 所以我有這個模型類在我的web服務:JAX-WS的wsimport不會保持toString()?
package webservice;
public class Book {
private String title;
private int pages;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
@Override
public String toString() {
return "Book [title=" + title + ", pages=" + pages + "]";
}
}
現在,我要生成一個Web服務客戶端所需的構件:
wsimport -keep http://localhost:8080/LibraryWs/BookWebServiceService?wsdl
,並得到結果類:
package webservice;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for book complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="book">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="pages" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="title" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "book", propOrder = {
"pages",
"title"
})
public class Book {
protected int pages;
protected String title;
/**
* Gets the value of the pages property.
*
*/
public int getPages() {
return pages;
}
/**
* Sets the value of the pages property.
*
*/
public void setPages(int value) {
this.pages = value;
}
/**
* Gets the value of the title property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTitle() {
return title;
}
/**
* Sets the value of the title property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTitle(String value) {
this.title = value;
}
}
所以沒有toString :)我在哪裏可以找到有關此行爲的規範或我怎樣才能讓jax-ws明確包含th在我的WSDL中的方法?謝謝。