I have a C# method that creates a request to a Java based web service. I serialize my class and post it to the service and it returns a status 400
indicating it can't find the named root element. When using fiddler I take the request and manually construct it in the Composer and process it and it succeeds. Using a hex viewer I notice that the request issued from C# has the following characters between the header and the request data EF BB BF
. The cut and pasted request I executed in Fiddler does not and it succeeds. As I am not well versed in the construction of Java Services would it be easier to find a way to tell Java to ignore the characters when processing the request or would it be easier to build yet another serializer in .Net? It is not my intent to start a religious war here just to get to the fastest possible solution.
The code to serialize looks like:
//seralize the Request
XmlSerializer msgSerializer = new XmlSerializer(Msg.GetType());
try
{
request = (HttpWebRequest)WebRequest.Create(_endpoint);
request.Method = "POST";
request.KeepAlive = true;
request.SendChunked = true;
using (Stream myRequestStream = request.GetRequestStream())
{
XmlTextWriter requestWriter = new XmlTextWriter(myRequestStream, Encoding.UTF8);
msgSerializer.Serialize(requestWriter, Msg);
myRequestStream.Close();
}
response = request.GetResponse();
}
catch (WebException webE)
{
//Yada Yada Yada
...
}