Reputation: 1118
I am currently working with a WSDL that has a method to save invoices. I have been able to modify existing invoices, but haven't figured out how to save new ones. Since the array size is immutable, I am unable to add objects to the array that is retrieved. How should I go about saving new invoices, and is there a way to add them into the array? The WSDL doesn't have another method for saving individual invoices.
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);
Upvotes: 0
Views: 99
Reputation: 3536
Why do you say the array is immutable? Does the 2nd to last line throw an error?
If it is in fact immutable, you can use Array.Clone
to copy the existing array and pass that. Alternatively, if the service is only expecting new/edited invoices to be passed to the SaveInvoices
operation (which makes more sense to me), you can do this:
//save invoices
_service.SaveInvoices(new [] {p});
Read about the Array.Clone method: https://msdn.microsoft.com/en-us/library/system.array.clone.aspx
Upvotes: 2