Esempio n. 1
0
        private void btnRESTCall_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                #region Get Rest URL Dynamically
                // This logic gets the rest version of the URL dynamically,
                string baseUri;
                string restUri;
                using (var sc = new ServiceReference.ServiceClient())
                {
                    var uri = sc.Endpoint.Address.Uri;
                    baseUri = uri.ToString().Replace(uri.Segments[uri.Segments.Length - 1], "");
                };
                restUri = baseUri + "rest";
                #endregion

                WebRequest  theRequest  = WebRequest.Create(restUri + "/Documents");
                WebResponse theResponse = theRequest.GetResponse();
                using (var reader = new StreamReader(theResponse.GetResponseStream()))
                {
                    dgREST.ItemsSource = JsonConvert.DeserializeObject <ServiceReference.Document[]>(reader.ReadToEnd());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 private void btnSOAPCall_Click(object sender, RoutedEventArgs e)
 {
     ServiceReference.ServiceClient ProxySOAP = new ServiceReference.ServiceClient();
     dgSOAP.ItemsSource = ProxySOAP.GetDocuments();
 }