wcf 服务器已拒绝客户端凭据

服务端配置
<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="netTcpExpenseService_ForSupplier" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
            hostNameComparisonMode="StrongWildcard" listenBacklog="10"
            maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
            maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>

    </bindings>
    <services>
      <!--联系人服务-->
      <service name="Service.Implement.Travel.Supplyer.Contact_Service">
        <endpoint address="net.tcp://10.1.3.203:9999/Service.Implement.Travel.Supplyer.Contact_Service"
           contract="Service.Interface.Travel.Supplyer.Contact_IService"
             binding="netTcpBinding" bindingConfiguration="netTcpExpenseService_ForSupplier"/>
      </service>

    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors" >

          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>


1,<security mode="Transport">  安全性修改   <security mode="None">
2,绑定监听配置 bindingConfiguration="netTcpExpenseService_ForSupplier" 
3,服务端设置<services>节点



客户端配置
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="netTcpExpenseService_ForSupplier" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"          

transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10"           

maxBufferPoolSize="20000000" maxBufferSize="20000000" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="8192000" maxArrayLength="8192000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
	<endpoint name="ContactService" address="net.tcp://10.1.3.203:9999/Service.Implement.Travel.Supplyer.Contact_Service"          

contract="Service.Interface.Travel.Supplyer.Contact_IService" binding="netTcpBinding" bindingConfiguration="netTcpExpenseService_ForSupplier"/>
    </client>
  </system.serviceModel>

1,<security mode="Transport">  安全性修改   <security mode="None">
2,绑定监听配置 bindingConfiguration="netTcpExpenseService_ForSupplier" 
3,客户端设置 <client>节点

总结:监听协议,服务端和客户端netTcpBinding节点配置保持一致.


调用wcf接口
                Contact_IService iwt = WCFClientProxy<Contact_IService>.GetReusableFaultUnwrappingInstance("ContactService");
                Contact model = new Contact();
                model.SupplierID = 4706;
                model.ContactType = 1;
                List<Contact> list = iwt.GetContactList(model);
                var query = list.Take(1).ToList();//默认取第一个
                string tel = string.Empty;
                string fax = string.Empty;
                foreach (var item in query)
                {
                    tel = item.ContactPhone;
                    fax = item.ContactFax;
                }
                Response.Write("电话:" + tel + "\n" + "传真:" + fax);



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值