WCF问题,客户端无法调用服务器端!!!!
在本地调用没问题,但到服务器上就报错“无法处理消息。这很可能是因为操作“http://tempuri.org/IServiceOutPats/GetOutPats”不正确,或因为消息包含无效或过期的安全上下文令牌,或因为绑定之间出现不匹配。如果由于未处于活动状态导致服务中止了该通道,则安全上下文令牌无效。若要防止服务永久中止闲置会话,请增加服务终结点绑定上的接收超时。”求大神指导
客户端代码:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IServiceOutPats">
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://160.100.1.246:81/HCSWebService/GetPatInfo/ServiceOutPats.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceOutPats"
contract="sa.IServiceOutPats" name="WSHttpBinding_IServiceOutPats">
<identity>
<servicePrincipalName value="160.100.1.246" />
</identity>
</endpoint>
</client>
</system.serviceModel>
服务器端代码
WCF Binding --------------------编程问答-------------------- 服务端配置<security mode="None"> 意思是说 基于wshttp的绑定不会进行token的交换。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="http" >
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="HCSWebService.GetPatInfo.ServiceInPats">
<host>
<baseAddresses>
<add baseAddress="http://160.100.1.246:81"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="http" contract="HCSWebService.GetPatInfo.IServiceInPats" />
</service>
<service name="HCSWebService.GetPatInfo.ServiceOutPats">
<host>
<baseAddresses>
<add baseAddress="http://160.100.1.246:81"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="http"
contract="HCSWebService.GetPatInfo.IServiceOutPats" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!--为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
<serviceMetadata httpGetEnabled="true" />
<!--要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
既然是none 还不如用basicHttpbinding试试 --------------------编程问答--------------------
这里面的 配置要改一下 你放在服务器上的网址变了啊http://tempuri.org/IServiceOutPats/GetOutPats 所以你的webconfig里面也需要改变的
补充:.NET技术 , Web Services