WCF FaultContract导致更新服务引用失败

时间:2010-01-19 14:45:14

标签: wcf

我有一个装有[ServiceContract]和[OperationContract]属性的IServiceFacade接口。当我从解决方案资源管理器通过VS2005执行更新服务引用时,它工作正常。现在我想将[FaultContract]属性添加到IServiceFacade接口中的所有方法。当我将属性添加到几个方法时,更新服务引用仍然有效。但是,如果修饰方法的数量达到一定数量,则服务引用的更新将失败。它似乎与使用错误契约修饰的方法无关。

这是服务合同:

[ServiceContract]
public interface IServicesFacade
{

    [OperationContract]
    [FaultContract(typeof(SecurityFault))]
    bool UserHasWriteRights();
    ...
}

以下是故障实施:

[DataContract]
public class SecurityFault
{
    private string _message;

    public SecurityFault (string message)
    {
        _message = message;    
    }

    [DataMember]
    public string Message
    {
        get { return _message; }
        private set { _message = value;}
    }
}

1 个答案:

答案 0 :(得分:3)

好的,我找到了原因和解决方案。基本上我的合约规模太大了。解决此问题的方法是将svcutil.exe.config文件添加到svcutil所在的目录 1 。配置应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>

    <client>
        <endpoint name="net.tcp" binding="netTcpBinding" bindingConfiguration="GenericBinding"
        contract="IMetadataExchange" />
        <endpoint name="http" binding="wsHttpBinding" bindingConfiguration="SecureBinding" contract="IMetadataExchange" />
    </client>

    <bindings>

        <netTcpBinding>
            <binding name="GenericBinding" maxBufferPoolSize="2147483647"
            maxReceivedMessageSize="2147483647" >
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                maxNameTableCharCount="2147483647" />
                <security mode="None"/>
            </binding>
        </netTcpBinding>

        <wsHttpBinding>
            <binding name="SecureBinding" maxBufferPoolSize="2147483647"
            maxReceivedMessageSize="2147483647" >
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                maxNameTableCharCount="2147483647" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
</system.serviceModel>
</configuration>

可以在http://geekswithblogs.net/claraoscura/archive/2007/08/20/114806.aspx

找到更多信息
  1. Visual Studio 2010中的默认路径为C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools