简体   繁体   中英

IndexOutOfRangeException when creating an Extension Codeunit for a Page Web Service

I'm trying to expose a Function in a Codeunit through a Page Web Service in Dynamics NAV (2009 R2). I followed the MSDN documentation and the steps in a blog post , but I'm getting the following error when connecting to the Web Service:

System.IndexOutOfRangeException : Index was outside the bounds of the array.

I've created a Page Web Service and a Codeunit Web Service , both using the same name, with only the Page Web Service published:

网页服务

My Codeunit contains only 1 Function for the moment and looks like this:

编码单位

When I publish the Codeunit Web Service as well, I can use it, but the Page Web Service still shows the error.

When I rename the Codeunit Web Service, the Page Web Service works again as before, without the Codeunit's Functions, of course.

Am I missing something or doing something wrong?

Function in your codeunit have wrong signature. Moreover in the blog it is Run function that is used (not user function). Don't know if it's matters.

Next phase: post the selected invoice. I don't have a method in my web service to post my invoice, so this is where we are going to extend the web service with this possibility. Very simple! I just created a codeunit with a function. In this function, the signature is important: the first parameter should be the same record variable of the page you published (in our case, "Sales Header"). This is my (only) function of my codeunit:

PostInvoice(precSalesinvoice : Record "Sales Header") CODEUNIT.RUN(CODEUNIT::"Sales-Post", precSalesinvoice);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM