如何将对象添加到 WSDL service system.array

本文关键字:WSDL service system array 添加 对象 | 更新日期: 2023-09-27 17:56:45

我目前正在使用具有保存发票方法的WSDL。我已经能够修改现有发票,但还没有弄清楚如何保存新发票。由于数组大小是不可变的,因此我无法将对象添加到检索到的数组中。我应该如何保存新发票,有没有办法将它们添加到数组中?WSDL 没有保存单个发票的另一种方法。

Invoices.InvoiceOrder[] po = _service.GetInvoices(_params, invoiceReturnProperties, rowReturnProperties);
//test import of new po
Invoices.InvoiceOrder newInvoice = new Invoices.InvoiceOrder();
//specify individual properties that need to be set
newInvoice.OrderId = 28;
newInvoice.CustomerName = "James Bond";
newInvoice.CustomerId = 28;
po[po.Length] = newInvoice; //not sure how to accomplish this
//save invoices
_service.SaveInvoices(po);

如何将对象添加到 WSDL service system.array

为什么说数组是不可变的?倒数第二行是否引发错误?

如果它实际上是不可变的,则可以使用 Array.Clone 复制现有数组并传递该数组。 或者,如果服务只期望将新的/编辑的发票传递给SaveInvoices操作(这对我来说更有意义),您可以这样做:

//save invoices
_service.SaveInvoices(new [] {p});

阅读有关 Array.Clone 方法的信息:https://msdn.microsoft.com/en-us/library/system.array.clone.aspx