小编Ste*_*utt的帖子

如何将服务引用与基本身份验证WCF SOAP服务一起使用

我有一个使用基本访问身份验证的WCF SOAP服务.SSL没有被使用 - 我理解这里的安全问题.

使用WCFTestClient应用程序我已经通过在服务中临时硬编码用户名和密码来验证服务的工作原理,当Authorization标头不存在时使用.

我现在正在尝试编写一个通过Authorization标头传递凭据的测试应用程序.我在我的测试应用程序中添加了对我的服务的服务引用,但Authorizationhttp请求中没有标题.生成的MyServiceClient类使用System.ServiceModel.ClientBase

在我的测试应用程序中,我将如下设置凭据

MyServiceClient client = new MyServiceClient("BasicHttpBinding_MyService");
client.ClientCredentials.UserName.UserName = "WebServiceUsername";
client.ClientCredentials.UserName.Password = "WebServicepassword";
Run Code Online (Sandbox Code Playgroud)

我也尝试过如下

MyServiceClient client = new MyServiceClient();
ClientCredentials loginCredentials = new ClientCredentials();
loginCredentials.UserName.UserName = "WebServiceUsername";
loginCredentials.UserName.Password = "WebServicepassword";
client.Endpoint.Behaviors.Remove(client.Endpoint.Behaviors.Find<ClientCredentials>()); 
client.Endpoint.Behaviors.Add(loginCredentials);
Run Code Online (Sandbox Code Playgroud)

服务web.config如下

<services>
  <service name="MyService" behaviorConfiguration="MyBehavior" >
    <endpoint contract="MyService" binding="basicHttpBinding" />
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
  </service>
</services>
Run Code Online (Sandbox Code Playgroud)

测试app.config如下

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_MyService">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint …
Run Code Online (Sandbox Code Playgroud)

wcf web-services basichttpbinding basic-authentication

7
推荐指数
1
解决办法
1万
查看次数

自定义SQL Server性能计数器

我需要为系统运行状况检查和监视创建多个计数器.由于有许多用于记录,报告和警告Windows Perfmon数据的工具,我希望将该数据发布为Perfmon计数器.

某些值需要来自SQL Server 2008数据库,例如,用作队列的表中的记录数以及表中最旧记录的年龄.虽然它看起来像这样可以通过使用来实现SQL Server中,用户可设置对象和存储过程sp_user_counter1sp_user_counter10这限制了我在每个服务器只有10个计数器,计数器名称和说明不能自定义,以反映计数器是什么.

如果不创建我们自己的应用程序来创建Perfmon计数器,还有其他方法可以在SQL Server中创建计数器吗?如果没有,是否有任何工具/项目允许使用SQL查询创建自定义计数器?

sql-server monitoring perfmon performancecounter sql-server-2008

5
推荐指数
1
解决办法
1172
查看次数