Search code examples
c#system.net.httpwebrequest

Insert soap envelope into web request in C# / Silverlight


I am trying to save Insert Soap Envelope Into WebRequest so I've created method

private static void InsertSoapEnvelopeIntoWebRequest(XDocument soapEnvelopeXml, HttpWebRequest webRequest)
        {
            using (Stream stream = webRequest.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }
        }

However there is problem, because:

'System.Net.HttpWebRequest' does not contain a definition for 'GetRequestStream' and no extension method 'GetRequestStream' accepting a first argument of type 'System.Net.HttpWebRequest' could be found (are you missing a using directive or an assembly reference?)


Solution

  • Silverlight doesn't have the synchronous GetRequestStream. You must use the asynchronous version BeginGetRequestStream.