【问题标题】:wcf service c# .net framework 4.5.1wcf服务c#.net框架4.5.1
【发布时间】:2020-11-13 21:11:51
【问题描述】:

我在 winform 上托管了一个 wcf 服务,当我在本地(同一服务器)调用该服务时它运行良好,但是客户端不同的 IP(同一域)它引发了异常: 无法处理该消息。这很可能是因为“http://tempuri.org/ICenterService/SaveCoursesIntoAllDevices”操作不正确,或者因为消息包含无效或过期的安全上下文令牌,或者因为绑定之间存在不匹配。如果服务因不活动而中止通道,则安全上下文令牌将无效。为防止服务过早中止空闲会话,请增加服务端点绑定的接收超时。

请帮帮我 谢谢

【问题讨论】:

  • 欢迎来到stackoverflow。请提供一个最小且可重复的示例。查看帮助主题,如何提出一个好的问题。
  • 您使用了什么绑定,您是否使用了 WCF 安全性?
  • @Dingpeng 这是绑定在服务器站点,在下面获取,我不使用wcf安全

标签: c# wcf


【解决方案1】:

根据你提供的配置文件,我发现你没有对端点应用WSHttpBinding_ICenterService。这可能是错误的原因,因为如果你使用wsHttpBinding并且客户端和服务器不在同一台计算机上,你需要设置security mode="None"

<services>
            <service behaviorConfiguration="CenterServer.Services.CenterServiceBehavior" name="Ecotek.Communication.HostWebService.CenterService">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://192.168.1.129:6085/SyncServices" />
                    </baseAddresses>
                </host>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                <endpoint address="" binding="wsHttpBinding" contract="Ecotek.Communication.HostWebService.ICenterService" bindingConfiguration="WSHttpBinding_ICenterService">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
            </service>
        </services>

您需要将绑定配置应用到端点。

【讨论】:

  • 你知道我花了2天的时间来解决问题,你的回答对我来说是金,非常感谢
【解决方案2】:

服务器站点:

        <wsHttpBinding>
            <binding name="WSHttpBinding_ICenterService" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false" maxReceivedMessageSize="2147483647" maxBufferPoolSize="1024768">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession enabled="true" />
                <security mode="None">
                    <transport clientCredentialType="None" />
                    <message clientCredentialType="None" negotiateServiceCredential="false" establishSecurityContext="false" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration="CenterServer.Services.CenterServiceBehavior" name="Ecotek.Communication.HostWebService.CenterService">
            <host>
                <baseAddresses>
                    <add baseAddress="http://192.168.1.129:6085/SyncServices" />
                </baseAddresses>
            </host>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <endpoint address="" binding="wsHttpBinding" contract="Ecotek.Communication.HostWebService.ICenterService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </service>
    </services>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多