Wednesday, February 3, 2010

Downloading webservice with wsdl


this.EnableViewState = false;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = "text/XML";
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yourewebsercvice.asmx?wsdl");  // change the url
request.Credentials=new NetworkCredential("sample name","password","domain");
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
Stream receiveStream =response.GetResponseStream();
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
string result=readStream.ReadToEnd ();
HttpContext.Current.Response.Write(result);
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + "fileName.xml");

No comments:

Post a Comment