Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a wcf service to get information from my azure database with works perfectly. Only thing is I have been stuck from the last two days calling the this wcf to get information into an android app. Can someone please help me as this is part of a project which needs to be done asap?

I have been following this tutorial on xamarins website but I can't seem to get the hang of it: Walkthrough working with WCF


Here is my c# android code:

        private SearchView _searchView;
        private ListView _listView;
        private ArrayAdapter _adapter;
        private DataTransferProcClient _client;
        public static readonly EndpointAddress EndPoint = new EndpointAddress("http://192.168.1.1:3190/DataTransferProcClient.svc");

        #region onCreate
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Load the UI defined in Location.axml
            SetContentView(Resource.Layout.location);

            InitializeDataCounty();

        }

private void InitializeDataCounty()
        {
            BasicHttpBinding binding = CreateBasicHttp();
            _client = new DataTransferProcClient(binding, EndPoint);
            _client.GetCountiesDataCompleted += ClientOnDataTransferProcCompleted;

        }

        private static BasicHttpBinding CreateBasicHttp()
        {
            BasicHttpBinding binding = new BasicHttpBinding
            {
                Name = "basicHttpBinding",
                MaxBufferSize = 2147483647,
                MaxReceivedMessageSize = 2147483647
            };

            TimeSpan timeout = new TimeSpan(0, 0, 30);
            binding.SendTimeout = timeout;
            binding.OpenTimeout = timeout;
            binding.ReceiveTimeout = timeout;
            return binding;
        }

        private void ClientOnDataTransferProcCompleted(object sender, GetCountiesDataCompletedEventArgs getCountiesDataCompletedEventArgs)
        {
            string msg = null;

            if (getCountiesDataCompletedEventArgs.Error != null)
            {
                msg = getCountiesDataCompletedEventArgs.Error.Message;
            }
            else if (getCountiesDataCompletedEventArgs.Cancelled)
            {
                msg = "Request was cancelled.";
            }
            else
            {
                msg = getCountiesDataCompletedEventArgs.Result.ToString();
            }
            RunOnUiThread(() => msg);
        }


Thanks
Posted
Updated 17-Apr-14 3:25am
v3
Comments
DamithSL 17-Apr-14 9:45am    
is there any reason for not generating proxy class for wcf service?
PatMeliaIreland 17-Apr-14 10:02am    
I have a proxy class created.
private DataTransferProcClient _client;
I am just badly stuck because this is my first time creating a mobile app in c#.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900