How to return a custom complex type in JAX-WS web

2019-07-21 03:11发布

问题:

I have been attempting recently to write a web service that returns a custom object. This object is very simple:

public class AppInfo {
private int AppID;
private String Appname;
private String AppDesc;
private String AppPriv;

public int GetAppID()
{ return this.AppID;}

public void SetAppID(int AppID)
{ this.AppID = AppID;}

public String GetAppName()
{ return this.Appname;}

public void SetAppName(String AppName)
{ this.Appname = AppName;}

public String GetAppDesc()
{ return this.AppDesc;}

public void SetAppDesc(String AppDesc)
{ this.AppDesc = AppDesc;}

public String GetAppPriv()
{ return this.AppPriv;}

public void SetAppPriv(String AppPriv)
{ this.AppPriv = AppPriv; }

public AppInfo()
{}
}

However for whatever reason when NetBeans generates the WSDL and XSD the AppInfo always returns with:

<xs:complexType name="appInfo">
<xs:sequence/>
</xs:complexType>   

Searching for any information on returning custom classes seems to lead me back to a rehash of either the calculator or the image web service, neither of which are useful to me. Is it not possible to return a custom object with JAX-WS?

回答1:

Most probably because you are not using the JavaBean standard for getters/setters? Try changing your getters/setters to

public String getAppPriv()
{ return this.AppPriv;}

public void setAppPriv(String AppPriv)
{ this.AppPriv = AppPriv; }