简体   繁体   English

如何在 C# 应用程序中从远程桌面访问 WCF 服务到另一台机器?

[英]How to access WCF service from Remote Desktop to another machine in c# application?

I have deploy WCF service on IIS of Remote Desktop Machine.我已经在远程桌面机器的 IIS 上部署了 WCF 服务。 I can be able to access that service in my local machine's chrome browser and I have added it as a service reference in my project.我可以在本地机器的 chrome 浏览器中访问该服务,并将其添加为我的项目中的服务引用。 Now when my project trying to access service then it's giving me error like The caller was not authenticated by the service.现在,当我的项目尝试访问服务时,它给了我错误,例如The caller was not authenticated by the service. . .

After r&d related to it I have added below lines for solution在与它相关的研发之后,我添加了以下几行解决方案

_client.ClientCredentials.Windows.ClientCredential.Domain = "RDP Computer name";
_client.ClientCredentials.Windows.ClientCredential.UserName = "RDP Username";
_client.ClientCredentials.Windows.ClientCredential.Password = "RDP Password";

and again when I try then error changed as a Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00).当我再次尝试时,错误已更改,因为Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00). Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00).

I try to find Domain name on RDP machine as per suggestion from https://support.microsoft.com/en-in/help/17463/windows-7-connect-to-another-computer-remote-desktop-connection .我尝试根据https://support.microsoft.com/en-in/help/17463/windows-7-connect-to-another-computer-remote-desktop-connection 的建议在 RDP 机器上查找域名。 But I didn't find any domain name there.但是我在那里没有找到任何域名。 it's workgroup name available in workgroup area.它是工作组区域中可用的工作组名称。

On my local machine project app.config file contains service code like below :在我的本地机器项目 app.config 文件中包含如下服务代码:

<system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IService1">
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://xx.xx.xxx.xxx/Testing/Service1.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IService1"
        contract="ServiceReference1.IService1" name="WSDualHttpBinding_IService1">
        <identity>
          <servicePrincipalName value="host/RDPName" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

however on WCF service project side web.config file contains below code :但是在 WCF 服务项目端 web.config 文件包含以下代码:

<protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

    <services>
      <service name="WcfService.Service1">
        <endpoint address="" binding="wsDualHttpBinding" contract="WcfService.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <timeouts closeTimeout="00:05:00" openTimeout="00:05:00" />
        </host>
      </service>
    </services>
    <bindings>
      <wsDualHttpBinding>
        <binding name="customBinding0"
                receiveTimeout="00:05:00"
                sendTimeout="00:05:00"
                openTimeout="00:05:00"
                closeTimeout="00:05:00"
                maxBufferPoolSize="2147483647"
                maxReceivedMessageSize="2147483647">
          <security mode="None">
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>

I am doing r&d from last few days for resolve this issue but not succeed at all.我从最近几天开始进行研发以解决此问题,但根本没有成功。

please can you suggest me that what should I do for resolve this one ?请你能建议我我该怎么做才能解决这个问题?

Thank you.谢谢你。

On my side, it works properly after setting up the windows credentials.在我这边,它在设置 Windows 凭据后正常工作。 This due to the fact that WCF created by the wsdualhttpbinding authenticates the client with windows credential by default.这是因为wsdualhttpbinding创建的 WCF 默认使用 Windows 凭据对客户端进行身份验证。
Besides, why does the service address have “Testing” prefix?另外,为什么服务地址有“Testing”前缀? And the service address is void.并且服务地址无效。 Are you using virtual path ?你在使用virtual path吗?
In fact, there is no need to use duplex binding.事实上,没有必要使用双工绑定。 Wshttpbinding is enough, or nettcpbinding , which also supports duplex communication. Wshttpbinding 就足够了,或者nettcpbinding ,它也支持双工通信。 Wsdualhttpbinding might be blocked by the firewall, since it supports the callback contract. Wsdualhttpbinding 可能会被防火墙阻止,因为它支持回调协定。
Please refer to the below discussion.请参考以下讨论。
WCF Duplex - Client is unable to finish the security negotiation within the configured timeout WCF Duplex - 客户端无法在配置的超时内完成安全协商
https://social.msdn.microsoft.com/Forums/en-US/21160b92-bed5-4e5d-a1a9-6fc8e84f6299/client-is-unable-to-finish-the-security-negotiation-within-the-configured-timeout-000000-the?forum=csf https://social.msdn.microsoft.com/Forums/en-US/21160b92-bed5-4e5d-a1a9-6fc8e84f6299/client-is-unable-to-finish-the-security-negotiation-within-the-configured- timeout-000000-the?forum=csf
https://help.octopus.com/t/client-is-unable-to-finish-the-security-negotiation-within-the-configured-timeout/6827 https://help.octopus.com/t/client-is-unable-to-finish-the-security-negotiation-within-the-configured-timeout/6827
Feel free to let me know if there is anything I can help with.如果有什么我可以帮忙的,请随时告诉我。
Updated.更新。
In order to rules out the authentication and network issue, I suggest you use Basichttpbinding to create the WCF service first.为了排除身份验证和网络问题,建议您先使用Basichttpbinding 创建WCF 服务。 The client-side could consume the service by adding service reference .客户端可以通过adding service reference来消费adding service reference please refer to the configuration.请参考配置。
Server-side.服务器端。

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="http"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

Look forward to your further message.期待您的进一步留言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM