Load WCf Service File

I am creating a WCF service that will upload and download xml files. When trying to download a file to a client, it throws the following error:

"The text type text / html; charset = utf-8 of the response message does not match the content type of the anchor (multipart / related; type = \" application / xop + xml \ "). Custom encoder, make sure the IsContentTypeSupported method is implemented correctly. First 1024 response bytes were: '\ nhttp: //www.w3.org/1999/xhtml \ "> \ n \ nIIS 7.0 Detailed error - 500.19 - Internal server error \ n \ n

I am using basicHTTPBinding as the binding protocol. My webservice is currently hosted on my own computer at IIS7.0 running Vista Home Premium. The download code in the service I'm 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 should download the file is the following using a normal 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, I don't understand what's wrong?

If you need more data to help me decide, let me know.

Thanks a lot, T

+2


source to share


1 answer


An "internal server error" should tip you back to the fact that it is a server that has a "maintenance" service issue. Your code doesn't even have the ability to execute lest it be the culprit. You need to make sure IIS is configured correctly.

Start by checking that your authentication mode is correct. If you are using impersonation, you need to enable that as well. If you are using an ASP.NET development server (the one that automatically starts on your machine when you start debugging), you should be aware that it is rather weak when it comes to your configuration. IIS is picky.



Most of the changes you make in IIS can also be reflected through your web.config, so be aware of the settings you made for IIS and reflect those changes in your web.config. This will ensure that problems do not recover again (for example, after another build).

If your project is a "WCF Service Application", you can see a more detailed error message by logging into the server where you are hosting the service and viewing the .svc file from a browser.

+1


source







All Articles