开发者

WCF FaultContract causes Update Service Reference to fail

开发者 https://www.devze.com 2022-12-17 00:56 出处:网络
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.

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 开发者_如何学Pythoninterface. 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.

Here is the service contract:

[ServiceContract]
public interface IServicesFacade
{

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

Here is the fault implementation:

[DataContract]
public class SecurityFault
{
    private string _message;

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

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


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>

More info can be found at http://geekswithblogs.net/claraoscura/archive/2007/08/20/114806.aspx


  1. The default path for that in Visual Studio 2010 is C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号