Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Consuming a WCF Service - needing some hand-holding I guess...........

$
0
0

I have a very simple WCF Service and I cannot for the life of me figure out how to call it from a PCL project. I have created a simple Winform application to test it out, and it's working fine. But, I cannot get it going from the PCL project. I have read through the guides, and I think the problem is that I'm needing something much simpler so I can understand it.

Here's the details:
In my WCF service, I have a call that accepts two two parameters and it returns a serialized string.

So, in my PCL project, I am trying the following:

        //Create the WCF Client 
        CrimcaseServiceClient client = new CrimcaseServiceClient(
            new BasicHttpBinding(),
            new EndpointAddress("http://localhost:9607/CrimcaseService.svc")
            );

        //Call the proxy - this should use the async versions
        client.GetCaseByNumCompleted += OnGotResult;
        client.GetCaseByNumAsync("13-02650", "");

    void OnGotResult(object sender, GetCaseByNumCompletedEventArgs e)
    {
        Device.BeginInvokeOnMainThread(async () =>
        {
            string error = null;
            if (e.Error != null)
                error = e.Error.Message;
            else if (e.Cancelled)
                error = "Cancelled";

            if (!string.IsNullOrEmpty(error))
            {
                await DisplayAlert("Error", error, "OK", "Cancel");
            }
            else
            {
                string results = e.Result;
            }
        });
    }

When I examine e, it is throwing a System.Reflection.TargetInvocationException error. Drilling down into it, I see it is a System.ServiceModel.EndpointNotFoundException that is being thrown.

Can anyone tell me what I'm doing wrong?

Thanks,
Brad


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>