Search
Closed
as Not Reproducible Help for as Not Reproducible

1
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 504288
Opened: 10/27/2009 12:37:17 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
I have two WebServices. One service is using the wsHttpBinding and other is using basicHttpBinding. Exception handling is working fine in wsHttpBinding but is failing for basicHttpBinding. I am using basicHttpBinding because this is a WebService defined for streaming the file download.


When i throw a FaultException<FileDownloadFault> from my Server code it is reaching the client as following:




The content type text/html 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: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>500 - Internal server error.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
'.


This is how i throw the error from webservice:


throw new FaultException<FileDownloadFault>(new FileDownloadFault() { errorMessage = "Requested file not found on the server" }, new FaultReason("FileNotFound"));

My Fault class has nothing special but only generice error code and message:




[DataContract(Namespace = "http://mynamespace/data")]
public class FileDownloadFault
{
    /// <summary>
    /// error code related to the fault
    /// </summary>
    [DataMember]
    public int errorCode { get; set; }

    /// <summary>
    /// error message related to the fault
    /// </summary>
    [DataMember]
    public string errorMessage { get; set; }

    /// <summary>
    /// Default Contract
    /// </summary>
    public FileDownloadFault()
    {

    }

}Following are the binding settings:


<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
     <service name="MyService" behaviorConfiguration="MyServiceBehavior">
        <endpoint contract="IMyService"
                 binding="basicHttpBinding"
                 bindingConfiguration="MyServiceBinding"
                 bindingNamespace="http://mynamespace/myservice"/>
     </service>
    </services>

    <bindings>
     <basicHttpBinding>
        <binding name ="MyServiceBinding"
         transferMode="Streamed"
         messageEncoding="Mtom"
         maxReceivedMessageSize="100485760" >
         <security mode="TransportWithMessageCredential" >
            <message clientCredentialType="UserName" />
         </security>
        </binding>
     </basicHttpBinding>
    </bindings>

    <behaviors>
     <serviceBehaviors>
     <behavior name="MyServiceBehavior">
         <serviceDebug includeExceptionDetailInFaults="true" />
         <serviceMetadata httpsGetEnabled="true" />
         <serviceCredentials>
            <userNameAuthentication
             userNamePasswordValidationMode="Custom"
             customUserNamePasswordValidatorType="MyServiceAuthentication, AssemblyName" />
         </serviceCredentials>
        </behavior>

     </serviceBehaviors>
    </behaviors>

</system.serviceModel>
</configuration>


If i change the transfer mode to Buffered it works fine. but that is not desirable, as we don't want to use streaming.




One weired thing is that - this works all fine if my client and server are running on the same machine. The exception is coming properly. But if i try to access the server from some other machine, i got that "500- Internal Server Error" rather than FileDownloadFault.



Is it some configuration problem.. like customErrorMessage flag for ASP.NET?


Please help me with this.
Details (expand)

Product Version

.NET Framework 3.5
Product Language
English

Operating System
Windows Server 2008 RTM/SP1/SP2
Operating System Language
English

Architecture
x64

Priority
(1=blocking, 2=important, 3=nice to have)
2

Severity
(1=major functionality issue, 2=important functionality issue, 3=nice to have)
2

Steps to Reproduce
As mentioned in description
Actual Results
As mentioned in description
Expected Results
As mentioned in description
Component Usage
(any information on your scenario that may help in investigating your issue)
 

How often does this happen?
Always Happens

Have you seen this problem in other versions?
I don't know if this issue existed previously
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 10/27/2009 at 2:55 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by Microsoft on 11/12/2009 at 3:00 PM
Thanks for reporting this issue! It is hard to tell without playing around your project as to what might be the problem. Is it possible for you a create a standalone project I could use to reproduce the issue? One thing you might want to try is make sure your client is also configured for transfermode streamed. The client may be using buffered mode causing this probem. Please reactivate the issue with more information.

Regards,
-Asad