Calling a webservice using a webclient RRS feed

  • Question

  • User-1700923934 posted

    How do I call a WCF webservice using WebClient. Where do i specify the servcie URL and method to be called and PArameters passed?

    Friday, January 10, 2014 2:47 PM


  • User-417640953 posted

    Hi np4,

    Thank you post the issue to asp.net forum.

    This is a commeon issue, "WebClient Class Provides common methods for sending data to and receiving data from a resource identified by a service URL."

    Lingaraj has provided a solution to consume WCF service (rest) like below code.

    WebClient client = new WebClient ();
    Stream data = client.OpenRead (http://www.dotnetperls.com/YourService.svc");
    StreamReader reader = new StreamReader (data);
    string s = reader.ReadToEnd ();
    Console.WriteLine (s);
    data.Close ();
    reader.Close ();

    For more information, please check below issue.


    Hope this helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 12, 2014 8:19 AM