I am having a wcf service and I am calling a method like this:
public static void f5()
{
var client = new WebClient();
client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);
var data = File.ReadAllText("request.xml");
client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
client.Headers.Add("SOAPAction", "some string");
client.UploadStringAsync(new Uri("http://differentdomain/wcf/Service.svc"), data);
}
public static void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
Console.WriteLine(e.ToString());
int cow = 0;
cow++;
}
static void Main(string[] args)
{
f5();
}
This program works perfectly when I don't use async method however the handler is not getting called soe some reason. The web service is hosted on a different computer on a different domain but the client and server are connected to same network. Most importanly everything works fine if I use UploadString instead.
Thanks