服务端配置
<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);
wcf 服务器已拒绝客户端凭据
最新推荐文章于 2021-08-02 17:24:20 发布