SukhjitSh4x0r
New Member
I am writing C# code for a WinRT Surface Tablet in Visual Studio Express 2012 for Windows 8. Although my xml is formatted (I am porting from apps on other platforms that work fine) I am apparently having trouble with the request syntax. I've been trying several different approaches and hit dead ends with the limitation of windows store apps in methods. The last I have tried is using HttpClient, HttpContent and HttpRequestMessage: (omitting the actual xml and urls, obviously)\[code\]string xmlSOAP = "..............[my soap xml]................."string url = "http://example.domain.com/myMagicalwebservice.asmx"string SOAPAction = "www.blahblah.com/doXMLStuff";HttpClient hc = new HttpClient();HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, url);req.Headers.Add("SOAPAction", SOAPAction);req.Method = HttpMethod.Post;req.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/soap+xml;charset=UTF-8");hc.SendAsync(req).ContinueWith(responseTask =>{ System.Diagnostics.Debug.WriteLine(responseTask.Result);});\[/code\]This results in a System.FormatException of "The format of value 'application/soap+xml;charset=UTF-8' is invalid."If I instead add the content type directly to the HttpContent instead of to HttpRequestMessage, I get the same outcome.If I simply comment out the line adding the content type (just doing dumb trial and error here) I receive a result with statuscode 415: "Unsupported Media Type."I have tried posting using the PostAsync method of HttpClient but I am unsure how to get the response using that.Any help would be very much appreciated, and I thank you in advance for your time!