WCF FaultContract 导致更新服务引用失败 [英] WCF FaultContract causes Update Service Reference to fail
问题描述
我有一个用 [ServiceContract] 和 [OperationContract] 属性修饰的 IServiceFacade 接口.当我从解决方案资源管理器通过 VS2005 执行更新服务参考时,它工作正常.现在我想将 [FaultContract] 属性添加到 IServiceFacade 接口中的所有方法.当我将属性添加到几个方法时,更新服务引用仍然有效.然而,如果装饰方法的数量达到一定数量,则服务引用的更新失败.好像和用错误契约修饰的方法没有任何关系.
I have an IServiceFacade interface decorated with a [ServiceContract] and [OperationContract] attributes. When I perform Update Service Reference via VS2005 from the solution explorer, it works fine. Now I want to add [FaultContract] attributes to all of the methods in the IServiceFacade interface. When I add the attributes to a couple of methods, Update Service Reference still works. If however the number of decorated methods reach a certain number, the update of the service reference fails. It doesn't seem to have anything to do with the methods that are decorated with fault contracts.
这是服务合同:
[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;}
}
}
推荐答案
好的,我找到原因和解决方案了.基本上我的合同规模太大了.解决此问题的一种方法是将 svcutil.exe.config
文件添加到 svcutil 所在的目录1.配置应如下所示:
Ok, I found the reason and solution. Basically my contract size got too large. A way to fix this is to add a svcutil.exe.config
file to the directory where the svcutil is located1. The config should look something like this:
<?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
- Visual Studio 2010 中的默认路径是
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
这篇关于WCF FaultContract 导致更新服务引用失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!