C# WCF客户端安全默认为Windows

C# WCF客户端安全默认为Windows,c#,wcf,web-services,C#,Wcf,Web Services,我正在尝试使用wsHTTPBinding和自定义用户名设置一个简单的WCF web服务。 我在远程服务器上安装了该服务,并在另一个端口上安装了自签名证书。 例如: 出于某种原因,客户端似乎默认使用windows安全性,即使我已将其设置为用户名安全性 这是我的web服务配置文件: <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> <customEr

我正在尝试使用wsHTTPBinding和自定义用户名设置一个简单的WCF web服务。 我在远程服务器上安装了该服务,并在另一个端口上安装了自签名证书。 例如:

出于某种原因,客户端似乎默认使用windows安全性,即使我已将其设置为用户名安全性

这是我的web服务配置文件:

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"></customErrors>
</system.web>
<system.serviceModel>
<services>
  <service name="AutoSenderWCF.Service1" behaviorConfiguration="Behavior1">
    <host>
      <baseAddresses>
        <add baseAddress="https://service.autosender.com.au:442/" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" bindingName="TransportBinding" contract="AutoSenderWCF.IService1"></endpoint>
    <endpoint address="mex"
      binding="mexHttpBinding"
      contract="IMetadataExchange" />
  </service> 

</services>
<bindings>
  <wsHttpBinding>
    <binding name="TransportBinding">
      <security mode="TransportWithMessageCredential">            
        <message clientCredentialType="UserName" />            
      </security>          
    </binding>        
  </wsHttpBinding>      
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="Behavior1">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>

      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="AutoSenderWCF.CustomValidator, AutoSenderWCF"/>

      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

和我的客户端代码(注意ethesecurity=windows)


明确指定在客户端配置中使用Windows:

 <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>


从服务器配置中复制该部分。

明确指定在客户端配置中使用Windows:

 <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>


从服务器配置中复制该部分。

我相信我已经解决了它: 这条线

<endpoint address="" binding="wsHttpBinding" bindingName="TransportBinding" contract="AutoSenderWCF.IService1"></endpoint>


它不应该是bindingName它应该是bindingConfiguration

我相信我已经解决了它: 这条线

<endpoint address="" binding="wsHttpBinding" bindingName="TransportBinding" contract="AutoSenderWCF.IService1"></endpoint>


它不应该是bindingName,应该是bindingConfiguration

是,但问题是我正在通过SVC Util创建配置。。所以我不知道它为什么会这样创建它?您是否尝试更新服务引用?MEX端点对客户端可用吗?也许只有WSDL没有这些信息,而且Url在客户端和服务器端是不同的。代理是否可能是为不同的实例生成的?不应该是。我不知道为什么服务生成器会输入这些信息。是的,但问题是我正在通过SVC Util创建配置。。所以我不知道它为什么会这样创建它?您是否尝试更新服务引用?MEX端点对客户端可用吗?也许只有WSDL没有这些信息,而且Url在客户端和服务器端是不同的。代理是否可能是为不同的实例生成的?不应该是。我不知道为什么服务生成器会输入这些信息。客户端和服务器的配置不同。您的问题是什么?客户端和服务器的配置不同。你的问题是什么?