none
How to access SAP services through Http service method in WPF application? RRS feed

  • Question

  • Hello All,

    Need help to access SAP based service url which returning json parameters through http method in WPF application.

    The same url accessing by normal browser while passing the credentials, i provided the same credentials in code also given proxy credentials too.

    Please refer following code tried 

     public async Task<string> get_web_content(string url)
            {
                Uri uri = new Uri(url);
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri) as HttpWebRequest;
                request.Proxy.Credentials = new NetworkCredential(Constants.strUserID,Constants.strPwd, Constants.Domain);

    request.Credentials = new NetworkCredential(Constants.strUserID,Constants.strPwd, Constants.Domain);           

    string received;

                using (var response = (HttpWebResponse)(await Task<WebResponse>.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null)))
                {
                    using (var responseStream = response.GetResponseStream())
                    {
                        using (var sr = new StreamReader(responseStream))
                        {

                            received = await sr.ReadToEndAsync();
                        }
                    }
                }

                return received;
            }

    Kindly refer this and help to consume the SAP services through WPF app.

    Thanks,

    Kalaivanan

    Tuesday, January 3, 2017 5:08 AM