今天在使用WCF調試時出現了以下異常
”無法處理消息。這很可能是因為操作“http://tempuri.org/IUserInfo/GetUserUserList”不正確,或因為消息包含無效或過期的安全上下文令牌,或因為綁定之間出現不匹配。如果由於未處於活動狀態導致服務中止了該通道,則安全上下文令牌無效。若要防止服務永久中止閒置會話,請增加服務終結點綁定上的接收超時“
服務器端的配置如下
<system.serviceModel>
<!--測試配置-->
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IUserInfo"
maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
<readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WCFMonitorInterface.UserInfoService">
<!-- Service Endpoints -->
<endpoint address="http://192.168.14.18:20005/UserInfoService/mex" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IUserInfo"
contract="WCFMonitorInterface.Interfaces.IUserInfo">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 為避免洩漏元數據信息,請在部署前將以下值設置為 false -->
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://192.168.14.18:20005/UserInfoService/metadata"/>
<!-- 要接收故障異常詳細信息以進行調試,請將以下值設置為 true。在部署前設置為 false 以避免洩漏異常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
客戶端配置如下
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IUserInfo"
maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
<readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.14.18:20005/UserInfoService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUserInfo"
contract="UserInfoService.IUserInfo" name="WSHttpBinding_IUserInfo">
<identity>
<userPrincipalName value="ludi\ODST" />
</identity>
</endpoint>
</client>
</system.serviceModel>
由於WCF服務是寄宿在一個控制台程序下,也做了一些初始設置,代碼如下
host.AddServiceEndpoint(typeof(IUserInfo), new WSHttpBinding(), uri);
if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null)
{
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
behavior.HttpGetUrl = new Uri(MetaUri);
host.Description.Behaviors.Add(behavior);
}
host.Opened += delegate
{
Console.WriteLine("WCF服務已開啟");
Console.WriteLine("WCF服務元數據地址:"+MetaUri);
};
host.Open();
以上,望解答,謝謝
http://blog.csdn.net/liudong8510/article/details/7329907