我正在發送包含數組的soap消息。我在我的代碼中遇到數組問題。它給出了上述錯誤,我到處尋找,甚至寫了一遍又一遍重寫了我的代碼,但我似乎無法找到我出錯的地方。webservices中的數組 - 對象引用未設置爲對象的實例
會如此感激如果有人能夠在正確的方向指向我:
UpdateRatePackages.IService.InventoryServiceClient isc = new UpdateRatePackages.IService.InventoryServiceClient();
UpdateRatePackages.IService.UpdateRatePackagesRequest ureq = new UpdateRatePackages.IService.UpdateRatePackagesRequest();
UpdateRatePackages.IService.UpdateRatePackagesOperationResponse ores = new UpdateRatePackages.IService.UpdateRatePackagesOperationResponse();
保護無效的Page_Load(對象發件人,EventArgs的) { SendSoapMessage(); }
保護無效SendSoapMessage() {
Int64 HID = 717759;
Int64 HRID = 85264;
int avail = 6;
// RateDetails.AvailabilityApplicationType val = RateDetails.AvailabilityApplicationType.SET;
for (int i = 0; i < ureq.RatePackages.GetLength(0); i++)
{
ureq.RatePackages[i].RatePackageId = HRID;
for (int j = 0; j < ureq.RatePackages[j].Rates.GetLength(0); j++)
{
ureq.RatePackages[i].Rates[j].Availability = avail;
ureq.RatePackages[i].Rates[j].AvailabilityApplicationType = UpdateRatePackages.IService.AvailabilityApplicationType.SET;
ureq.RatePackages[i].Rates[j].FromDate = Convert.ToDateTime("2012-03-21");
ureq.RatePackages[i].Rates[j].ToDate = Convert.ToDateTime("2012-03-31");
}
// isc.UpdateRatePackages(request);
}
數據定義爲Web服務:
public class UpdateRatePackagesRequest
{
public string Username;
public string Password;
public UpdateRatePackageRequest[] RatePackages;
}
public class UpdateRatePackageRequest
{
public Int64 RatePackageId;
public RateDetails[] Rates;
}
public class RateDetails
{
public decimal Rate;
public enum RateApplicationType { SET, INCREASE, DECREASE, INCREASE_PERCENT, DECREASE_PERCENT } ;
public int Availability;
public enum AvailabilityApplicationType { SET , INCREASE, DECREASE };
public bool StopSell;
public string Inclusions;
public int MinimumNightStay;
public DateTime FromDate;
public DateTime ToDate;
}
public class UpdateRatePackageResult
{
public Int64 RatePackageId;
public Boolean Success;
public string Message;
}
public class UpdateRatePackagesResponse
{
public UpdateRatePackageResult[] Result;
}
是我的問題在陣列或者它有什麼做的肥皂消息本身?
行,其中突出顯示錯誤:
對(INT I = 0;我< ureq.RatePackages.GetLength(0);我++)
請幫助!
什麼是堆棧跟蹤?哪一行發生異常? – Kiril 2012-03-27 04:12:25
在線100上,我已經粘貼在引號 – user1270384 2012-03-27 04:15:36
OH上面的那一行,得到了它......確定那麼無論是'ureq'還是'RatePackages'都是'null',你是否嘗試設置一個斷點並檢查其中一個那些? – Kiril 2012-03-27 04:19:31