我在我的Eclipse項目中有一個代理類,用於項目使用Web服務。代理類看起來像這樣(從嚮導自動生成的代碼)在Eclipse中更改Web服務java代理方法返回類型
public class WebServiceUpg2SoapProxy implements org.uppgift2.www.WebServiceUpg2Soap {
private String _endpoint = null;
private org.uppgift2.www.WebServiceUpg2Soap webServiceUpg2Soap = null;
public WebServiceUpg2SoapProxy() {
_initWebServiceUpg2SoapProxy();
}
public WebServiceUpg2SoapProxy(String endpoint) {
_endpoint = endpoint;
_initWebServiceUpg2SoapProxy();
}
private void _initWebServiceUpg2SoapProxy() {
try {
webServiceUpg2Soap = (new org.uppgift2.www.WebServiceUpg2Locator()).getWebServiceUpg2Soap();
if (webServiceUpg2Soap != null) {
if (_endpoint != null)
((javax.xml.rpc.Stub)webServiceUpg2Soap)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
else
_endpoint = (String)((javax.xml.rpc.Stub)webServiceUpg2Soap)._getProperty("javax.xml.rpc.service.endpoint.address");
}
}
catch (javax.xml.rpc.ServiceException serviceException) {}
}
public String getEndpoint() {
return _endpoint;
}
public void setEndpoint(String endpoint) {
_endpoint = endpoint;
if (webServiceUpg2Soap != null)
((javax.xml.rpc.Stub)webServiceUpg2Soap)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
}
public org.uppgift2.www.WebServiceUpg2Soap getWebServiceUpg2Soap() {
if (webServiceUpg2Soap == null)
_initWebServiceUpg2SoapProxy();
return webServiceUpg2Soap;
}
public org.uppgift2.www.ObjectOwner[] getObjectOwner() throws java.rmi.RemoteException{
if (webServiceUpg2Soap == null)
_initWebServiceUpg2SoapProxy();
return webServiceUpg2Soap.getObjectOwner();
}
public org.uppgift2.www.RealEstateBroker[] getRealEstateBroker() throws java.rmi.RemoteException{
if (webServiceUpg2Soap == null)
_initWebServiceUpg2SoapProxy();
return webServiceUpg2Soap.getRealEstateBroker();
}
public org.uppgift2.www.Showing[] getShowing() throws java.rmi.RemoteException{
if (webServiceUpg2Soap == null)
_initWebServiceUpg2SoapProxy();
return webServiceUpg2Soap.getShowing();
}
public org.uppgift2.www.ProspectiveBuyer[] getProspectiveBuyers() throws java.rmi.RemoteException{
if (webServiceUpg2Soap == null)
_initWebServiceUpg2SoapProxy();
return webServiceUpg2Soap.getProspectiveBuyers();
}
public org.uppgift2.www.RealEstateObject[] getRealEstateObjects() throws java.rmi.RemoteException{
if (webServiceUpg2Soap == null)
_initWebServiceUpg2SoapProxy();
return webServiceUpg2Soap.getRealEstateObjects();
}
}
我在另一個類的方法創建代理類的實例,並調用它的方法
public TableModel getObjectOwner() {
WebServiceUpg2SoapProxy proxy2 = new WebServiceUpg2SoapProxy();
List<ObjectOwner> oo = null;
try {
oo = proxy2.getObjectOwner();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return buildTableModel(oo);
}
這使我一個錯誤說
類型不匹配:不能從ObjectOwner []轉換到列表
我的問題是;如何將代理的返回類型從ObjectOwner []更改爲List?這可以在嚮導中完成嗎?
我知道在Visual Studio中,您只需右鍵單擊解決方案資源管理器中的服務器引用,然後轉到配置參考,然後在提示窗口中對其進行更改。這可以在Eclipse中完成嗎?
在此先感謝。
是的你是對的。這將解決我的問題。謝謝。 – Marcus