I'm trying to create a .Net Standard 1.3 library which wraps a WCF service for cross-platform usage. I use Visual Studio's "Create Service Reference" in a .Net Framework project to auto-generate the bulk of the code, and then reference that auto-generated code from the .Net Standard library and wrap it in a layer which manages ChannelFactory and Channel instances.
The auto-generated code supports synchronous and task-based asynchronous invocation. When I call the synchronous versions of the methods from Android they work, but when I call the asynchronous methods I get errors indicating that the generated SOAP message included "Async" in the name incorrectly.
The problem is observed with Xamarin.Android 18.104.22.168.
Because this is quite complicated I've put the minimal reproducible test case on GitHub at https://github.com/pjt33/PortableWCFSandbox . The solution contains four projects:
1. DemoService.WCF is the service. I've deployed it to Azure as https://demoservicewcf.azurewebsites.net/DemoService.svc and include the code in the GitHub project solely for completeness. This service has one remote method, `Reverse`, which reverses a string.
2. FrameworkClient is a .Net console project which has an auto-generated service reference and calls `Reverse` both synchronously and asynchronously.
3. NetStandardClientLib is a .Net Standard 1.3 project which uses FrameworkClient's auto-generated reference code and wraps it in a simple proxy. It has a NuGet reference to System.ServiceModel.Http.
4. AndroidClientIndirect is a Xamarin Android project which references NetStandardClientLib. It also calls `Reverse` both synchronously and asynchronously.
Both FrameworkClient and AndroidClientIndirect should be able to make synchronous and asynchronous calls.
Alternatively, if asynchronous calls are not supported then an error message should be thrown which clearly states that asynchronous calls are not supported.
FrameworkClient successfully makes synchronous and asynchronous calls. AndroidClientIndirect successfully makes synchronous calls, but the asynchronous call throws
System.AggregateException: One or more errors occurred. ---> System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Error in deserializing body of request message for operation 'Reverse'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'Reverse' and namespace 'urn:fdc:cheddarmonk.org:2017:Demo'. Found node type 'Element' with name 'ReverseAsync' and namespace 'urn:fdc:cheddarmonk.org:2017:Demo'
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) FrameworkClient.Bar.IDemoService:ReverseAsync (string)
at NetStandardClientLib.DemoServiceProxy+<ReverseAsync>d__3.MoveNext () [0x0002e] in C:\Users\pjt33\Documents\Visual Studio 2015\Projects\PortableWCFSandbox\NetStandardClientLib\DemoServiceProxy.cs:51
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00014] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2157
at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x00034] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:562
at System.Threading.Tasks.Task`1[TResult].get_Result () [0x00000] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:532
at AndroidClientIndirect.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0006e] in C:\Users\pjt33\Documents\Visual Studio 2015\Projects\PortableWCFSandbox\AndroidClientIndirect\MainActivity.cs:28