简体   繁体   中英

Xamarin C#: System.Reflection.TargetInvocationException

I need consume a WebService(SOAP) in a Xamarin.Forms APP. I import the webService as "Service Reference" in PCL.

Then i call the webService as:

  //...oncreate
    Guid g1 = new Guid("3f0c9ec7-9382-403d-8480-7142a7fd65d9");
    ws.GetNotificacionesAsync(g1);
    ws.GetNotificacionesCompleted += ws_GetNotificacionesCompleted;

void ws_GetNotificacionesCompleted(object sender, WSPuentesUsuario.GetNotificacionesCompletedEventArgs e)
            {
                int a = 12;
            }

Finally, "e" show this error: Result = System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

( int a = 12; is only used to breakpoint) PD: I use this link how example http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/

I found the problem. Xamarin Android need to comunicate the HttpGet and HttpPost protocols. These protocols must be generated on SideServer. Adds protocols this form:

https://msdn.microsoft.com/en-us/library/4yx7be39(v=vs.100).aspx

Finally: System.reflexion.Exception can be caused by a null response from server.(Incorrect protocols)

PD: Remember use the browser on emulator/device to see the correct navegation to webService(link webService), also remember that localhost is a invalid link to device/emulator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM