How to call a SOAP web service in .NET 4.0 C# without using the WSDL or proxy classes

If you want to call a .NET 4.0 C# web service, without using the WSDL or “Add Service Reference” in Microsoft Visual Studio 2010. You can use the following functions:

/// <summary>
/// Execute a Soap WebService call
/// </summary>
public override void Execute()
    HttpWebRequest request = CreateWebRequest();
    XmlDocument soapEnvelopeXml = new XmlDocument();
    soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:soap="""" xmlns:xsi="""" xmlns:xsd="""">
    <HelloWorld3 xmlns="""">
    using (Stream stream = request.GetRequestStream()) 

    using (WebResponse response = request.GetResponse())
        using (StreamReader rd = new StreamReader(response.GetResponseStream())) 
            string soapResult = rd.ReadToEnd();
/// <summary>
/// Create a soap webrequest to [Url]
/// </summary>
/// <returns></returns>
public HttpWebRequest CreateWebRequest()
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@""); 
    webRequest.ContentType = "text/xml;charset=\"utf-8\""; 
    webRequest.Accept = "text/xml"; 
    webRequest.Method = "POST"; 
    return webRequest; 


<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><HelloWorld3Response xmlns=""><HelloWorld3Result>test</HelloWorld3Result></HelloWorld3Response></soap:Body></soap:Envelope>


You can use complex types in you’re request. I use fiddler to get the contents of the soap envelope.