Reputation: 425
I've created a WCF service with a method GetTestValue
. I've also created a test application to test this service.
When I add this WCF service with connected service to the test application I can only call GetTestValueAsync
, there is no GetTestValue
method. Somehow this add process add this async thing behind the method name. So in this test application, the WCF call works fine when I call GetTestValueAsync
. I get the result back.
Then I've created a Xamarin cross application app where I added this WCF service too, and when I call the GetTestValueAsync
from this application I get the following error:
Error in deserializing body of request message for operation 'GetTestValue'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetTestValue' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'GetTestValueAsync' and namespace 'http://tempuri.org/'
Somehow strange in the test project it works fine, and in the Xamarin cross application not.
Async
to my method name?How can I stop this Async
being added to the method name?
Thanks for any help.
Upvotes: 1
Views: 973
Reputation: 1
I know this is old, but I had the same problem and searched a while. When you are adding the Reference in your project, you can check "generate synchronized operations" and the "Async"-suffix aren't generated anymore. My VS runs in german language, so I just translated the options. If your adding new methods the setting will be considered too.
Greetings from germany.
Upvotes: 0
Reputation: 2882
At the moment Xamarin apps aren't compatible with the Task-based asynchronous WCF proxy methods that the WCF Web Service Reference connected service provider generates (bugzilla.xamarin.com Bug 51959).
One way to generate an older, compatible style of WCF proxy methods is to run SvcUtil.exe
with the /async
and /tcv:Version35
switches in a Developer Command Prompt. That will generate synchronous proxy methods, Begin/End style Asynchronous Programming Model (APM) callback proxy methods, and event-based proxy methods, all of which are compatible with Xamarin apps.
(Note: If you leave out the /async
switch, SvcUtil.exe
will generate the newer, incompatible Task-based proxy methods.)
Duplicate: By chance, I replied on a more recent duplicate of this question first: How to use WCF services in .netstandard with Xamarin.Forms project?
Upvotes: 1