locked
Can't add a Web Service RRS feed

  • Question

  • User348547 posted

    Hello Xamarin Developers,

    I wanted to ask if any of you have managed to get your application connected to a Web Service asmx. I get always an TargetInvocation error and i have searched many times but i cant get to a solution. Basically i use it like this: I have followed some tutorials they go and change the targetFrameworkProfile from 259 to 78 in order to make a Service Reference option visible in the Portable options, so we can get the web service connected.

    I write the code like this:

        private void btn_Clicked(object sender, EventArgs e)
        {
        myWebService.ServiceWebSoapClient ws = new myWebService.ServiceWebSoapClient();
    
        ws.LoginAsync();
        ws.LoginCompleted += Ws_LoginCompleted;
        }
    
        private void Ws_LoginCompleted(object sender, myWebService.LoginCompletedEventArgs e)
        {
        if (e.Result.ValidUser)
        lblTest.Text = " Service works";
        else
        Device.BeginInvokeOnMainThread(() =>
        {
        DisplayAlert("Error", "Username gabinm", "OK");
        });
        }
    

    I checked many other tutorials but it doesnt work. On the e.result i always get the error TargetInvocation error.

    And now with the .net Standard and wcf Service it gets another error, it just throws an error in scaffolding where the new option for adding a wcf service has appeared.

    There are many discussions about this but i never found a solution.

    If anyone could help me i would gladly appreciate it.

    P.S. I know how to do it with WEB API. And also it didnt work with TODO asmx.

    Tuesday, June 26, 2018 1:34 PM

All replies

  • User2148 posted

    I dont understand sorry

    Are you able to create csharp Classes with vs2017 tool?

    Tuesday, June 26, 2018 2:17 PM
  • User348547 posted

    @AlessandroCaliaro said: I dont understand sorry

    Are you able to create csharp Classes with vs2017 tool?

    Of course. This is the tutorial i followed : https://www.youtube.com/watch?v=pIfSp8XtrA0

    I had to change the TargetFramework Profile so i can get the Add Service tool in the Project Portable tools. Can you tell me what you dont understand ?

    Tuesday, June 26, 2018 2:20 PM