2

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!

asked Mar 27, 2012 at 3:30
4
  • What's the stack trace? Which line is the exception occurring on? Commented Mar 27, 2012 at 4:12
  • On line 100 that is the line I have pasted on top in quotes Commented Mar 27, 2012 at 4:15
  • OH, got it... ok then either ureq or RatePackages is null, have you tried setting a break point and checking either one of those? Commented Mar 27, 2012 at 4:19
  • Yes RatePackages is null, how do I fix this? Commented Mar 27, 2012 at 4:22

1 Answer 1

1
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.

answered Mar 27, 2012 at 4:21

15 Comments

RatePackages is null, how can I fix that?
@user1270384 take a look at whatever is supposed to set RetePackages and ensure that it's setting it to a valid value. I don't know what your code looks like, so I can't tell you much more than that. May the force be with you! :)
ok thanks for trying to help. Is there something I may be missing from my code above that I can add to assist you?
@user1270384 This should be pretty basic stuff... almost as basic as "hello world." At the very minimum, you should initialize your array, here is one way to initialize the array: int[] numbers = new int[10]; Populating it is a matter of creating a for-loop for(int i = 0; i < numbers.Length; i++) and storing a number in each element of the array.
Feel free to post another question that's more specific and remember to tag the question with the relevant tags (that will get more people to see it).
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.