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

泄露秘密 提交于 2020-01-04 06:49:13

问题


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; }


来源:https://stackoverflow.com/questions/12955313/how-to-return-a-custom-complex-type-in-jax-ws-web-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!