WCF WsDualHttpBinding服务

时间:2017-10-15 18:11:53

标签: c# .net web-services wcf iis

我正在尝试使用WCF( WsDualHttpBinding )实现一个简单的聊天服务,这样我就可以使用回调。

我的WCF服务托管在Arvixe共享托管下的IIS(我相信8.5​​)下。

当我在我的电脑上测试我的客户端和我的服务时,一切都像魅力一样。当我在Arvixe主机上发布我的服务并尝试从我的电脑上运行的客户端应用程序打开连接时(使用visual studio),我得到:“调用者未经过服务认证”。

该服务在此处托管: http://www.4greatsoft.com/WebService/ChatSVC.svc

我也可以通过以下方式获取服务说明: http://www.4greatsoft.com/WebService/ChatSVC.svc?wsdl

客户端PC上的防火墙已关闭。

我在CLIENT(app.config)端的服务模型配置为:

<system.serviceModel>
    <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IChat" />
        </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://www.4greatsoft.com/WebService/ChatSVC.svc"
            binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IChat"
            contract="IIS_ChatSVC.IChat" name="WSDualHttpBinding_IChat">
            <identity>
            <userPrincipalName value="PINE\4greatsoftcom_web" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我在SERVER(web.config)端的服务模型配置是:

<system.serviceModel>
    <protocolMapping>
        <add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" />
    </protocolMapping>
    <bindings>
        <wsDualHttpBinding>
            <binding name="wsDualHttpBindingConfiguration" transactionFlow="true" >
            </binding>
        </wsDualHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"  />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
        <service name="ServiceAssembly.ChatService">
            <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" contract="ServiceAssembly.IChat" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

这些服务模型配置将产生“调用者未通过服务”错误进行身份验证。

关于stackoverflow的许多建议,我尝试使用服务模型配置关闭安全性,但是这样做时我收到以下超时错误: “打开的操作未在分配的超时内完成00:00:09.7659996。“

我在CLIENT(app.config)端的服务模型配置(导致超时)是:

<system.serviceModel>
    <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IChat" closeTimeout="00:00:10"
                openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:10"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <reliableSession ordered="true" inactivityTimeout="00:10:00" />
            <security mode="None">
                <message clientCredentialType="None" negotiateServiceCredential="false" />
            </security>
        </binding>
        </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://www.4greatsoft.com/WebService/ChatSVC.svc"
            binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IChat"
            contract="IIS_ChatSVC.IChat" name="WSDualHttpBinding_IChat">
        </endpoint>
    </client>
</system.serviceModel>

我在SERVER(web.config)端的服务模型配置(导致超时)是:

<system.serviceModel>
    <protocolMapping>
        <add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" />
    </protocolMapping>
    <bindings>
        <wsDualHttpBinding>
            <binding name="wsDualHttpBindingConfiguration" closeTimeout="00:00:10"
                    openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:10"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                <security mode="None" />
            </binding>
        </wsDualHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
        <service name="ServiceAssembly.ChatService">
            <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBindingConfiguration" contract="ServiceAssembly.IChat" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

重要: 请注意,在我的用例中使用“ WsDualHttpBinding ”是强制性的,因为我正在使用WCF的CallBack功能。所以不,我不能使用“HttpBasicBinding”。

说实话,我必须承认,就网络安全而言,我是一个完全的菜鸟,我对如何解决这个问题毫无头绪。我已经进行了一次“试错”狂欢超过3天,尝试各种排列到我的服务模型配置而没有成功......

那就是说,我会问任何可能的帮助者是否准确无误,而不是假设我是这个主题的专家......

我相信这篇文章(WCF Client not able to negotiate security access with Service running in a different machine)接近解释我的问题,但我仍然看不出我的解决方案必须是什么。

此时我几乎愿意与WCF / IIS专家签约,只要我知道在哪里找到一个......

谢谢大家的关注。

0 个答案:

没有答案