HellOfACode HellOfACode - 9 months ago 79
C# Question

MS DynamicsNAV Web service index out of bounds

Hi Im having problems with Microsoft Dynamics NAV 2009 R2 Web Service!

There is a webMethod given called OrderGoodsInsert which needs parameters lLanguageId [int], lRec [Text 250] [100]

lRec should be a string array with values such as these

  1. "Document Type"

  2. "Document No."

  3. "Line No." - (empty at creation)

  4. "Insert User"

  5. "Modify User"

  6. "Type" [0 – „”, 1 – G/L Account, 2 – Item, 3 – Resource, 4 – Fixed Asset, 5 – Charge (Item)]

  7. "No." – item code

  8. Quantity

Using c# code I try to call the method that is added as a web service reference to my project. The code:

string[] arr = new string[8];
arr[0] = "1";
arr[1] = currentDocNo;
arr[3] = "SU04";
arr[5] = "2";
arr[6] = item.Code;
arr[7] = item.Amount;
arr[2] = "";
arr[4] = "";

navWS.OrderGoodsInsert(1062, arr);

But when I do I get

A first chance exception of type 'System.Net.WebException'
occurred in System.dll
A first chance exception of type 'System.Web.Services.Protocols.SoapException'
occurred in System.Web.Services.dll

The error is that
index out of bounds

Am I doing something wrong?

Answer Source

The problem was that the developer of the WS made changes and did not send out a new documentation. One more string was needed in the array which represented the shelf the item is on.