0

您好我在使用 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

难道我做错了什么?

4

2 回答 2

0

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

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

所以它期待string变量lRec的 a 而不是 a string[]

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

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

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

于 2016-10-25T12:12:50.317 回答
0

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

于 2016-11-01T08:02:03.250 回答