如何在c#应用程序中从远程桌面访问WCF服务到另一台机器?
我已在远程桌面计算机的IIS上部署WCF服务。我可以在本地机器的chrome浏览器中访问该服务,并将其作为服务参考添加到我的项目中。现在,当我的项目尝试访问服务时,它会给我一个错误,比如如何在c#应用程序中从远程桌面访问WCF服务到另一台机器?,c#,wcf,iis,wcf-data-services,C#,Wcf,Iis,Wcf Data Services,我已在远程桌面计算机的IIS上部署WCF服务。我可以在本地机器的chrome浏览器中访问该服务,并将其作为服务参考添加到我的项目中。现在,当我的项目尝试访问服务时,它会给我一个错误,比如调用方没有通过服务的身份验证。 在与it相关的研发之后,我在下面添加了一行内容以供解决 _client.ClientCredentials.Windows.ClientCredential.Domain = "RDP Computer name"; _client.ClientCredentials.Window
调用方没有通过服务的身份验证。
在与it相关的研发之后,我在下面添加了一行内容以供解决
_client.ClientCredentials.Windows.ClientCredential.Domain = "RDP Computer name";
_client.ClientCredentials.Windows.ClientCredential.UserName = "RDP Username";
_client.ClientCredentials.Windows.ClientCredential.Password = "RDP Password";
再次尝试时,错误更改为客户端无法在配置的超时(00:00:00)内完成安全协商。当前谈判阶段为1(00:00:00)。
我尝试在RDP机器上按照来自的建议查找域名。但是我在那里没有找到任何域名。它是工作组区域中可用的工作组名称
在我的本地计算机上,项目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>
但是,在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>
为了解决这个问题,我最近几天一直在做研发工作,但根本没有成功
你能建议我该怎么解决这个问题吗
谢谢。在我这方面,它在设置windows凭据后工作正常。这是因为默认情况下,
wsdualhttpbinding
创建的WCF使用windows凭据对客户端进行身份验证。此外,为什么服务地址有“测试”前缀?服务地址无效。您正在使用虚拟路径吗?
事实上,不需要使用双工绑定。Wshttpbinding就足够了,或
nettcpbinding
,它也支持双工通信。Wsdualhttpbinding可能被防火墙阻止,因为它支持回调协定。请参阅下面的讨论。
如果有什么我可以帮忙的,请随时告诉我。
已更新。
为了排除身份验证和网络问题,我建议您首先使用Basichttpbinding创建WCF服务。客户端可以通过添加服务引用来使用服务。请参考配置。
服务器端
<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>
期待您的进一步消息。您可能能够通过RDP连接到远程计算机,因为RDP端口在防火墙处打开,但您可能无法访问任何其他端口,因为防火墙可能会阻止此操作。同样对于工作组设置,用户帐户不能跨不同的计算机。你最好通过广告@LexLi建立一个域名。我尝试设置入站规则,允许该端口用于传入请求。但在这种情况下它不起作用。但是让我尝试设置新域名。请创建一个active directory域。这样您的服务器就能够对kerberos或NTLM令牌进行身份验证。此外,您必须确保80个端口已暴露于internet。我指的是服务器门户中的服务器内部防火墙和外部防火墙。“我尝试通过允许该端口设置入站规则”,您为WCF打开了哪个端口?请说清楚。谢谢你的答复。我尝试了您提供的链接,但我的应用程序仍然无法访问我在RDP IIS服务器上部署的服务。请你给我指一下这个好吗?