locked
how to connect web services RRS feed

  • Question

  • Hai,

    i am developing an windows8 app. Here my question is i am having some web services, how can i use this web services to my application.

    Thursday, October 3, 2013 6:56 AM

Answers

  • Use Add Service Reference in the Project Explorer (context menu on References), enter URI and VS will create classes you can use to communicate with the service.
    • Marked as answer by sarika ala Thursday, October 3, 2013 7:28 AM
    Thursday, October 3, 2013 7:16 AM

All replies

  • Use Add Service Reference in the Project Explorer (context menu on References), enter URI and VS will create classes you can use to communicate with the service.
    • Marked as answer by sarika ala Thursday, October 3, 2013 7:28 AM
    Thursday, October 3, 2013 7:16 AM
  • Thank you..

    this answer helps me alot. can you suggest me any sample or any example so that i can make use of this in my application.

    Thursday, October 3, 2013 7:39 AM
  • Search the samples maybe there's something. But it's rather simple. You should know what you want, what endpoints the service has, etc. I use the following in my project for a WCF service. You need to create a binding and an address manually. You create an instance of your service and use it and then close it when you are done with it. It's just a fragment, but it should be self-explanatory.

            private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(Properties settings)
            {
                System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
                result.MaxBufferSize = int.MaxValue;
                result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
                result.MaxReceivedMessageSize = int.MaxValue;
                result.AllowCookies = true;
                result.OpenTimeout = TimeSpan.FromMinutes(2);
                result.TextEncoding = new System.Text.UTF8Encoding();
                result.TransferMode = System.ServiceModel.TransferMode.Streamed;
                if (settings.SecureConnection)
                {
                    result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
                }
                else
                {
                    result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.None;
                }
                return result;
            }

            private static System.ServiceModel.EndpointAddress GetEndpointAddress(Properties settings)
            {
                string uri;
                if (settings.SecureConnection)
                    uri = string.Format("https://{0}/Pflege/ServicePflegeMobile.svc/safe", settings.Server);
                else
                    uri = string.Format("http://{0}/Pflege/ServicePflegeMobile.svc/ServicePflegeMobile.svc", settings.Server);
                return new System.ServiceModel.EndpointAddress(uri);
            }

                    var service = new sage200pflegeservicemobileClient(GetBindingForEndpoint(Settings), GetEndpointAddress(Settings));
                    var info = await service.DoSomethingAsync();


    • Edited by IvanIL Thursday, October 3, 2013 8:01 AM
    Thursday, October 3, 2013 7:59 AM