wcf错误,怎么解决?大牛救救我!!!!

BestLifeForUs 2017-11-02 05:57:42
客户端可以成功添加服务引用并引用,但用到wcf服务的时候会出现以下错误:

“System.ServiceModel.FaultException”类型的未经处理的异常在 mscorlib.dll 中发生

其他信息: The message could not be processed. This is most likely because the action 'http://tempuri.org/Iservice/test' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

客户端app。config配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_Iservice" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" >
<security mode="None" >
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.141:8081/my.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_Iservice" contract="SQL.Iservice"
name="WSHttpBinding_Iservice">
<identity>
<servicePrincipalName value="host/wang-11f9ae7746" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WpfApplication1.Service1">
<endpoint address="" binding="basicHttpBinding" contract="WpfApplication1.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WpfApplication1/Service1/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>


服务端配置:
<configuration>
<system.serviceModel>
<services>
<service name="MySystem.sql" behaviorConfiguration="metadataExchange">
<!--协定contract为接口-->
<endpoint address="" binding="wsHttpBinding" contract="MySystem.Iservice"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataExchange">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyServiceBinding" closeTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>

ps:我把服务端的basicHttpBinding改为wsHttpBinding后调用服务就出现响应消息的内容类型 text/html; charset=utf-8 与绑定(application/soap+xml; charset=utf-8)的内容类型不匹配的错误

急,感谢回答!
...全文
197 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
BestLifeForUs 2017-11-03
  • 打赏
  • 举报
回复
csdn这么垃圾?
BestLifeForUs 2017-11-03
  • 打赏
  • 举报
回复
ddddddddddddddddddddddddddddddddddddddddd
BestLifeForUs 2017-11-03
  • 打赏
  • 举报
回复
没人知道 ???????????????
peng2739956 2017-11-03
  • 打赏
  • 举报
回复
WCF 这玩意 没人愿意回答,光看定位不出具体的问题。你这东西报错了。有很多方面的原因。自己找找比较合适。 如果是代码方面,早有人回答了
ljhls1012 2017-11-03
  • 打赏
  • 举报
回复
我认为应该是你给的积分点太少了,要么你再等等

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧