Consume WebService without creating proxy RRS feed

  • Question

  • User1939450320 posted


    I have a webservice http://.....asmx 

    I would like to consume this webservice in my WCF service. I do not want to add service reference for webservice.

    Can any one help me how to communicate with webservice with out adding service reference in wcf service.

    Friday, March 8, 2013 10:30 AM


  • User-1662538993 posted

    Try this -

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost/WebServices/CustomerWebService.asmx");
    req.Headers.Add("SOAPAction", "\"http://tempuri.org/Register\"");
    req.ContentType = "text/xml;charset=\"utf-8\"";
    req.Accept = "text/xml";
    req.Method = "POST";
    using (Stream stm = req.GetRequestStream())
         using (StreamWriter stmw = new StreamWriter(stm))
    WebResponse response = req.GetResponse();
    Stream responseStream = response.GetResponseStream();
    // TODO: Do whatever you need with the response

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 8, 2013 11:52 AM