Dear all.
I am creating WCF service that will download & upload xml files. When trying to download a file to a client, it gives me the following error:
*"The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (multipart/related; type=\"application/xop+xml\"). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' \n \n \nIIS 7.0 Detailed Error - 500.19 - Internal Server Error \n \nmargin-top:0px; \n border-top:1px solid #EDEDED;border-left:1px solid #EDEDED;border-right:1px solid #969696; \n border-bottom:1px solid #969696;background:#E7ECF0;font-weight:bold;'."
I am using basicHTTPBinding as my binding protocol. My webservice is currently hosted on my own pc on IIS7.0 under Vista Home Premium. The download code in the service I am using is the following:
public Stream Download( string path )
{
try
{
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return stream;
}
}
catch (Exception ex)
{
string error = ex.Message;
return null;
}
}
The code on my client that is supposed to download the file is the following, using just an ordinary test file:
System.IO.FileStream fs;
try
{
fs = (System.IO.FileStream)client.Download(@"C:\UploadedFiles\Test.txt");
byte[] arr = new byte[fs.Length];
int read;
do
{
read = fs.Read(arr, 0, arr.Length);
} while (read != arr.Length);
Console.WriteLine(ASCIIEncoding.ASCII.GetString(arr));
Console.ReadLine();
}
catch (Exception Ex)
{
string error = Ex.Message;
string inner = Ex.InnerException.ToString(); ;
Console.WriteLine("Exception: {0}/nInner Exception: {1}",error,inner);
Console.ReadLine();
}
Someone please help me out, I don't understand what is wrong?
If you need more data to help me resolve, also let me know.
Thanks a lot, T