繁体   English   中英

使用 IIS 托管服务时出现问题 - 本地和远程

[英]Problem consuming IIS hosted service - locally and remotely

我为我目前正在进行的项目构建了 2 个服务。

1) 一个使用 basicHttpBinding 的简单客户端-服务器请求服务

2) 使用 WSDualHttpBinding 的回调数据服务

通过一些操作,我能够同时在 IIS 中托管,并且可以在本地浏览器中访问 :/Service.svc ,也可以在另一台与这两种服务交互的机器上访问。

这是回调数据服务的 app-config 部分

    <system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <behavior name="myBehavior">
        <clientVia />
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IDataService">
              <security mode="None">
                <message negotiateServiceCredential="false" clientCredentialType="None" />
              </security>
            </binding>
          </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://<address>:50111/Service.svc/service"
            binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IDataService" behaviorConfiguration="myBehavior"
            contract="CallbackService.IDataService" name="WSDualHttpBinding_IDataService">
        </endpoint>
    </client>
</system.serviceModel>

basicHttpBinding 看起来非常相似 - 仅适用于另一个端口

我将 IIS 设置为匿名身份验证 .. 用户 IUSR,无密码 ..

最初它在本地工作 - 但是从远程计算机我收到了身份验证错误..所以我做了更多调整 - 现在我什至在本地也会超时..尽管 Visual Studio 与两个服务的服务引用交互得很好。

如何让服务再次“合作”

我不知所措 - 非常感谢任何帮助!?

编辑:第一个问题解决了 - 本地通信恢复

public ClientCallbacks myCallbacks=new ClientCallbacks();      
public DuplexChannelFactory<IDataService> channelFactory { get; set; }
public IDataService channel;

public int connect() {
    WSDualHttpBinding binding = new WSDualHttpBinding() 
        { Name = "WSDualHttpBinding_IDataService" };
    this.channelFactory = new DuplexChannelFactory<IDataService>(
        mainForm.dbCommunication.myCallbacks,
        binding,
        new EndpointAddress("http://<address>:50111/Service.svc/service"));
    this.channel = this.channelFactory.CreateChannel();
...
...
channel.AddListener(int-parameter); // announce new callback-partner
...
...
 this.newListe = this.myCallbacks.receivedTaskList; //get Tasklist over callback

这在本地工作 - 但远程调用它我收到一个“新”错误

System.ServiceModel.Security.SecurityNegotiationException:
  The caller was not authenticated by the service. ---> 
  System.ServiceModel.FaultException: The request for security token could not be satisfied
 because authentication failed.
   at System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault
    (Message message, EndpointAddress target)
at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody
    (Message incomingMessage, SspiNegotiationTokenProviderState sspiState)
--- End of inner exception stack trace ---

我再次努力寻找线索/解决方案......我将 IIS 身份验证设置为匿名......但似乎在到达该点之前通信被阻止......我必须做什么才能从远程机器访问服务?

似乎我们应该提供凭据以使服务器端对客户端进行身份验证。 应提供哪种凭据取决于服务器端的绑定配置。
默认情况下。 WsDualhttpbinding的安全模式配置为Message安全模式,客户端凭证类型为Windows。
下面这些代码片段是等效的。

WSDualHttpBinding binding = new WSDualHttpBinding();

WSDualHttpBinding binding = new WSDualHttpBinding();
            binding.Security.Mode = WSDualHttpSecurityMode.Message;
            binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

从您的代码片段中,我没有看到您对服务器端的配置。 如果需要 Windows 凭据,请考虑以下代码段。

//ChannelFactory<IService> channelFactory = new ChannelFactory(...);
            channelFactory.Credentials.Windows.ClientCredential.UserName = "administrator";
            channelFactory.Credentials.Windows.ClientCredential.Password = "123456";
            IService svc = channelFactory.CreateChannel();

如果问题仍然存在,请随时告诉我。

暂无
暂无

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

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