【问题标题】:MS DynamicsNAV Web service index out of boundsMS DynamicsNAV Web 服务索引超出范围
【发布时间】:2017-03-07 10:31:00
【问题描述】:

您好,我在使用 Microsoft Dynamics NAV 2009 R2 Web 服务时遇到问题!

有一个名为 OrderGoodsInsert 的 webMethod 需要参数 lLanguageId [int], lRec [Text 250] [100]

lRec 应该是一个字符串数组,包含这些值

  1. “文档类型”
  2. “证件号”
  3. “行号” - (创建时为空)
  4. “插入用户”
  5. “修改用户”
  6. “类型”[0 – „”, 1 – 总账科目, 2 – 项目, 3 – 资源, 4 – 固定资产, 5 – 费用(项目)]
  7. “没有。” – 商品代码
  8. 数量

使用 c# 代码,我尝试调用作为 Web 服务引用添加到我的项目的方法。代码:

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);

但是当我这样做时,我得到了

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

错误是index out of bounds

我是不是做错了什么?

【问题讨论】:

  • OrderGoodsInsert 的 SOAP 请求看起来如何?这是服务器端异常还是客户端?请将您的函数的 WSDL 部分添加到问题中。
  • 另外,item.Code 包含什么值?
  • 一个字符串,例如“0067444”
  • dpaste.de/PHBd 希望我明白你想要什么
  • 从 NAV 方面看,lRec 是一个 100 维的 Text250 变量,对吧?那么,我相信,arr 变量的大小应该是 100 而不是 8。

标签: c# navision dynamics-nav dynamics-nav-2009


【解决方案1】:

您的 OrderGoodsInsert 方法在 SOAP 定义上看起来像这样

<sequence>
  <element minOccurs="1" maxOccurs="1" name="lLanguageId" type="int"/>
  <element minOccurs="1" maxOccurs="unbounded" name="lRec" type="string"/>
</sequence>

因此,变量lRec 需要string,而不是string[]

尝试将数组转换为带有分隔符的单个字符串。

navWS.OrderGoodsInsert(1062, string.Join(";", arr));

但我不确定哪一个是 NAV WebServices 的正确分隔符。

【讨论】:

  • 好吧,当我像处理数组一样执行此操作时,我会被扔到 reference.cs 文件中,该文件包含我试图调用的函数 dpaste.de/Me2m 它是在将 webReference 添加到项目时生成的。 object[] results = this.Invoke("OrderGoodsInsert", new object[] { lLanguageId, lRec}); 是引发异常的行。
  • @HellOfACode index out of bounds 通常意味着您的数组比预期的要大。这个例外已经是网络服务器的答案了吗?难道IRec 的其中一列是自动创建的并且没有暴露给WebService?也许Line No.
  • 我正在尝试联系我们公司的文档开发人员。很快就会更新。
【解决方案2】:

问题在于 WS 的开发人员进行了更改并且没有发送新的文档。 数组中还需要一个字符串来表示该项目所在的架子。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    相关资源
    最近更新 更多