locked
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

Answers

  • 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.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/c896b564-7a9b-423d-a42d-d36c33c46e7d/consume-a-wcf-service-as-a-url?forum=wcf

    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