4

after a server call my client catches an exception with the following message

"The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error."

Also, note I tried the configuration in WCF "The server did not provide a meaningful reply" but still didn't work.

Please note, that I debug the service to the end, and the data is successfully populated but at the client end when the data is supposed to appear it just crashes with the mentioned exception.

Any help appreciated.

Community
  • 1
  • 1
Amr Elsehemy
  • 983
  • 4
  • 12
  • 24
  • You'll need to put more information about your service contract and config files to get meaningful help. This message usually means the service failed to respond within the either default or custom timeout limit set in the service configuration. – Sixto Saez Apr 26 '11 at 18:41

5 Answers5

3

If someone else comes across this same exception, with the same behavior of debugging to the end in the server, but getting the exception on the return to the client, another possible cause is an uninitialized enum in the return data contract where the enum has explicit values, but no explicit zero value.

[ServiceContract]
public interfact IMyService
{
    [OperationContract]
    MyResult DoSomething();
}

[DataContract]
public class MyResult
{
    [DataMember]
    public OperationStatus Status {get; set;}

    [DataMember]
    public string ErrorText {get; set;}
}

[DataContract]
public enum Operation Status
{
    [EnumMember]
    Success = 1,
    [EnumMember]
    Failure = 2
}

public class MyService : IMyService
{
    public MyResult DoSomething()
    {
        var result = new MyResult();

        // ... do work, but don't set any properties on result ...

        return result;

    }
}

The reason the error happens in this scenario is that result.Status defaults to zero, but the data contract does not provide any means to serialize it, since it is not one of the explicitly defined enum values.

The solution (assuming you really do need this enum with explicit integer values) is to either set the enum value in the return object, or provide a default (zero) value.

[DataContract]
public enum Operation Status
{
    [EnumMember]
    Unknown = 0,
    [EnumMember]
    Success = 1,
    [EnumMember]
    Failure = 2
}

--Bill

Bill
  • 41
  • 1
  • 1
    Your answer prompted me to check my enums and see if any had not been assigned to zero. Sure enough, one of them only had values of 1 and 2 in it. Assigned a member called Unknown and set it to zero and it fixed my problem. Thanks so much – John C Jan 25 '14 at 00:18
3

I figured out the reason behind this that the proxy was wrongly generated for an enum type, it was generated as a string so it failed and gave me out that exception

Amr Elsehemy
  • 983
  • 4
  • 12
  • 24
2

if your web service return a DataTable, it must have TableName; look at https://stackoverflow.com/a/5894732/775811

Community
  • 1
  • 1
0

The cause of this error for me was a missing FaultContractAttribute(typeof(FaultModel)) on the Server function interface (The one marked with OperationContract attribute).

When the FaultException< FaultModel >() was thrown on the server side the client side was throwing - CommunicationException: "The server did not provide a meaningful reply this might be caused by a contract mismatch, a premature session shutdown or an internal server error.".

Hope will help someone.

Claudiu Mihaila
  • 1,262
  • 8
  • 16
0

This happened to me on a new system (Windows 10) after trying to call a Windows Workflow service. Other WCF service calls were working, but trying to call the workflow activity (a xamlx WF4 service) received this error.

Trying to browse to the service.xamlx file resulted in a blank screen. That eventually led me to this other answer (the IIS8 specific answer), which is to add the HTTP Activation feature under IIS Services:

WCF on IIS8; *.svc handler mapping doesn't work

Stephen Rauch
  • 40,722
  • 30
  • 82
  • 105
jcm
  • 23
  • 4