Forum Xamarin.Forms

Can't call WCF methods in Xamarin.Forms (Cross-Platform)

AlipAlip Member ✭✭
edited June 2018 in Xamarin.Forms

I just create a simple WCF project with default values (without change even a single line of code), i publish it in web, Consume it in EXE application and it work fine, Cosume it in webform and it work fine.

Now i create another simple Xamarin Cross-Platform with .Net Standard 2 (UWP, iOS, Android), Used "Microsoft WCF Web Service Reference Provider" and i checked all 3 project in UWP work fine but in android and iOS project load and after click the button can't call GetDataAsync().

Xamarin button clicked code :

Service1Client client = new Service1Client(Service1Client.EndpointConfiguration.BasicHttpsBinding_IService1);
string returnString;
returnString = await client.GetDataAsync(Convert.ToInt32(entNumber.Text));
lblResult.Text = returnString;
await client.CloseAsync();

Android runtime error after clicked button :

Unhandled Exception:
System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Error in deserializing body of request message for operation 'GetData'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetData' and namespace ''. Found node type 'Element' with name 'GetDataAsync' and namespace ''

iOS runtime error after clicked button :

Unhandled Exception:
System.InvalidOperationException: MonoTouch does not support dynamic proxy code generation. Override this method or its caller to return specific client proxy instance

Funny thing is UWP work fine and return method string just fine.
This is my first experience to consume WCF in xamarin.forms and i feel maybe i do something wrong.


Sign In or Register to comment.