Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

SOAP envelope request and get respose using c#

$
0
0

I have third party company given us URL and SOAP envelop format , now I need to request i have used below method but gives me errors.

I have string soapenv =

 HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://thirdparycompanydom.com/");
                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))
                    {
                        stmw.Write(soapenv);
                    }
                }

                WebResponse response = req.GetResponse();
               
                StreamReader responseStream =new  StreamReader(response.GetResponseStream());
                lbl.Text = responseStream.ReadToEnd();
                responseStream.Close();


this gives me error

System.Net.WebException: The remote server returned an error: (500) Internal Server Error

what it could be, do you think my code have erros


Viewing all articles
Browse latest Browse all 555

Trending Articles