从代码隐藏创建WCF绑定

时间:2012-09-06 10:22:19

标签: wcf sharepoint wcf-binding

我正在开发一个使用WCF服务的SharePoint工作流 - 事实上,我无法正确部署app.config文件。这就是我所说的:

<configuration>
<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:55693/Service1.svc" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
            name="WSHttpBinding_IService1">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我无法找到如何动态地设置代码,有人会这么善良并指出我正确的方向吗?

1 个答案:

答案 0 :(得分:5)

它就像appconfig一样工作:

WSHttpBinding binding = new WSHttpBinding();
binding.Name = "WSHttpBinding_IService1";
...
binding.ReaderQuotas.MaxDepth = 32;
...
binding.Security.Mode = SecurityMode.Message;
...
相关问题