I am posting XML file to Web services using C# . My work is generating a xml file from object of my application then I should send it on the business Gateway of Monster.com . I tried this method for sending but I encountred an error "The remote server returned an error: (403) Forbidden." Please Help ! public void sendFileToWebservice(string file) { string xmlString = System.IO.File.ReadAllText("C:/Users/DELL/Documents/Visual Studio 2012/Projects/testXML/testXML/file.xml"); string url = "https://gateway.monster.com:8443/bgwBroker"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(xmlString); req.Method = "POST"; req.ContentType = "text/xml;charset=utf-8"; req.ContentLength = requestBytes.Length; Stream requestStream = req.GetRequestStream(); requestStream.Write(requestBytes, 0, requestBytes.Length); requestStream.Close(); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default); string backstr = sr.ReadToEnd(); sr.Close(); res.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)