Reputation: 721
I am sending soap messages that contains arrays. I have problems with arrays in my code. It gives the above errors, I've looked everywhere, even wrote and rewrote my code over and over again but I can't seem to find where I am going wrong.
Would be so grateful if somebody can point me in the right direction:
UpdateRatePackages.IService.InventoryServiceClient isc = new UpdateRatePackages.IService.InventoryServiceClient();
UpdateRatePackages.IService.UpdateRatePackagesRequest ureq = new UpdateRatePackages.IService.UpdateRatePackagesRequest();
UpdateRatePackages.IService.UpdateRatePackagesOperationResponse ores = new UpdateRatePackages.IService.UpdateRatePackagesOperationResponse();
protected void Page_Load(object sender, EventArgs e) { SendSoapMessage(); }
protected void 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);
}
Data Defined as in the webservice:
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;
}
Is my problem in the arrays or does it have something to do with the soap message itself?
line where error is highlighted:
for (int i = 0; i < ureq.RatePackages.GetLength(0); i++)
Please help!
Upvotes: 2
Views: 342
Reputation: 40395
for (int i = 0; i < ureq.RatePackages.GetLength(0); i++)
If the error is happening there, then either ureq
or RatePackages
is null
. Step through in the debugger and see which one is null
. It does look like you're setting ureq
, but you should check both anyway.
Upvotes: 1