【问题标题】:WCF FaultContract causes Update Service Reference to failWCF FaultContract 导致更新服务引用失败
【发布时间】:2010-01-19 14:45:14
【问题描述】:

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

这是服务合同:

[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;}
    }
}

【问题讨论】:

  • @trendl:您应该只更新您的原始问题,而不是用其他信息回答您自己的问题。我将您的合同定义移到您原来的问题中 - 您能否删除您不需要的答案?谢谢!
  • 嗯...这很奇怪 - 您的代码完全没有明显的问题 - 我觉得很好。

标签: wcf


【解决方案1】:

好的,我找到了原因和解决方案。基本上我的合同规模太大了。解决此问题的一种方法是将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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多