Skip to content

Instantly share code, notes, and snippets.

@belchev
Last active January 13, 2016 15:09
Show Gist options
  • Save belchev/04580878904cadd984f7 to your computer and use it in GitHub Desktop.
Save belchev/04580878904cadd984f7 to your computer and use it in GitHub Desktop.
WCF send custom header request - dirty way
string url = "http://url.com/*.wsdl";
using (var client = new WebClient())
{
var data = System.IO.File.ReadAllText(HostingEnvironment.MapPath(@"~/App_Data/request.xml"));
client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
client.Encoding = Encoding.GetEncoding("ISO-8859-1");
client.Credentials = new NetworkCredential("username", "pass");
client.Headers.Add("SOAPAction", "\"http://url.com/wsdl?action\"");
var response = client.UploadString("http://url.com/wsdl", data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment