1

I just started working on xamarin not long ago.

Now I met a problem on Xamarin consuming AX2012 Webservice.

I’m in a project that need an android device connect with AX2012 R3 Inbound port.

I made a very simple webservice like below and tested successfully by using C# project.

AX Webservice code

[SysEntryPointAttribute(true)]
public ItemNameAlias GetItemName(ItemId itemId)
{
    return InventTable::find(itemId).NameAlias;
}

C# invoke code(successful)

static void Main(string[] args)
{
    TestWebservice.TestWebserviceClient client = new TestWebservice.TestWebserviceClient();
    TestWebservice.CallContext cpny = new TestWebservice.CallContext() { Company = "USMF" };

    client.ClientCredentials.Windows.ClientCredential.UserName = @"sagcn\wangy";
    client.ClientCredentials.Windows.ClientCredential.Password = "aoc-111";

    string itemName = client.GetItemName(cpny, "C0004");
    Console.WriteLine($"Item Name: {itemName}");

    Console.ReadKey(false);
}

When I add this service reference to an Xamarin.form project, it was been used very like in C# project. But when the code invoked the webservice function, it throws a System.NotImplementedException exception. System.NotImplementedException Message=The method or operation is not implemented.

Xamarin code (throw NotImplementedException exception)

private void Button_Clicked(object sender, EventArgs e)
{
    string itemName = "";
    Debug.WriteLine("Start");

    ASMXService.TestWebserviceClient client = new ASMXService.TestWebserviceClient();
    ASMXService.CallContext cpny = new ASMXService.CallContext() { Company = "USMF" };

    client.ClientCredentials.Windows.ClientCredential.UserName = @"sagcn\wangy";
    client.ClientCredentials.Windows.ClientCredential.Password = "aoc-111";

    // throw exception here
    itemName = client.GetItemName(cpny, "C0004");

    Debug.WriteLine($"Item Name: {itemName}");

    Debug.WriteLine("End");            
}

I searched many places but still don’t know the reasons why.

Does anyone have the same experience or can give me some advice?

Thanks a million.

AX Webservice code

C# project add web reference

C# project code success

Xamarin add WCF Webservice

Xamarin add WCF Webservice2

Xamarin invoke webservice

Error exception

CFSR
  • 11
  • 1
  • WCF can be an incredible nightmare to work with. I strongly suggest you find a way to implement RESTful services instead. – Jason Jul 21 '22 at 10:45
  • Unfortunately your issue is going to be difficult to answer in this setting because there are so many variables. I agree with @Jason and a good method I've used is to wrap the AX AIF services with a .NET proxy + Azure Service Bus to expose it externally. This link is a great start if that's a viable option for you https://devblog.sertanyaman.com/2021/01/11/how-to-integrate-dynamics-ax-2012-with-azure-and-power-platform/ . You ultimately end up with a standalone service running on your AOS and then you can use a modern API to interface with AX. – Alex Kwitny Jul 21 '22 at 15:57

0 Answers0