Announcements
Hi,
I developed a simple service in AX2012 which only has a method for counting everytime the service gets consumed.
[SysEntryPointAttribute(true)] public int ContadoraAvrAvr() { _Counter ; return _Counter; }
But when I try to consume it in a C# console project I receive the error No overload for method takes 0 arguments. But my method does not need any arguments.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ConsumeBasicCustomService.ContadoraServicioGrupo; namespace ConsumeBasicCustomService { class Program { static void Main(string[] args) { ContadoraServicioClient contadoraServicioVar; contadoraServicioVar.ContadoraAvrAvr(); Console.WriteLine(); Console.ReadLine(); } } }
If you don't want to provide any parameters, you can simply create a new, empty CallContext:
contadoraServicioVar.ContadoraAvrAvr(new CallContext());
If you want to set some values, you need to create an instance of CallContext and set its properties. This example is copied from AX documentation:
// Create an instance of the CallContext class. CallContext context = new CallContext(); // Set the value for Company. context.Company = "dat"; // Set the value for LogonAsUser. context.LogonAsUser = @"yourdomain\userid"; // Set the value for language. context.Language = "en-us";
You could also use different syntax for the same thing:
// Create an instance of the CallContext class. CallContext context = new CallContext { Company = "dat", LogonAsUser = @"yourdomain\userid", Language = "en-us" };
Then you'll pass the object to your method:
contadoraServicioVar.ContadoraAvrAvr(context);
Hi Martin,
I understand now that I need a CallContext object, however I dont know exactly how I should code this based on what I have.
What would likely help is knowing what parameters the method actually expects, which you can easily see in Visual Studio, e.g. by typing contadoraServicioVar.ContadoraAvrAvr( and checking IntelliSense.
You'll find that the methods needs a CallContext object.
As you see, the parameter profile of the service operation and the method in the proxy class don't have to be identical.
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator