我有一个ASMX webservice并且有一个返回ArrayList的方法。工作正常,但我不知道如何从客户端代码中获取Array项。这是asmx方法
[WebMethod]
public ReturnParcel[] getConStrings(string dbType)
{
var OdbName = GetSetting(document, "Odbname");
var OuserName = GetSetting(document, "Ousername");
var Opassword = GetSetting(document, "Opassword");
if (dbType == "Oracle")
{
return new ReturnParcel[] {new ReturnParcel { DBName = OdbName, UserID = OuserName, Password = Opassword },};
}
else
{
return new ReturnParcel[] {new ReturnParcel { DBName = SdbName, UserID = SuserName, Password = Spassword },};
}
}
public class ReturnParcel
{
public string DBName { get; set; }
public string UserID { get; set; }
public string Password { get; set; }
}
客户代码:
WebServiceProxy.OraSPDataXchange objServiceClient = new WebServiceProxy.OraSPDataXchange();
objServiceClient.Url = "http://portal.mydomain.local/_layouts/SPCustomWS/OraSPDataXchange.asmx";
objServiceClient.getConStrings("Oracle");
检查客户端代码的最后一行..我需要获取返回的值..所以需要知道如何在这里得到它..
答案 0 :(得分:2)
我假设
var receivedConnectionStrings = objServiceClient.getConStrings("Oracle");
会将结果放在receivedConnectionStrings
变量中。