Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF SecurityNegotiationException正在尝试远程访问_C#_Wcf - Fatal编程技术网

C# WCF SecurityNegotiationException正在尝试远程访问

C# WCF SecurityNegotiationException正在尝试远程访问,c#,wcf,C#,Wcf,我在IIS 6上部署了WCF Web服务。我现在部署它,创建一个网站并使用默认设置 我可以在我的Webbrowser中看到DNSService.svc?wsdl,这样我就可以访问这个站点。但,若我在VS项目中创建一个WebReference,并尝试运行WebService的一个方法,则程序将在SecurityNegotiationException中运行。Messagetext说Web服务无法对调用方进行身份验证。但为什么我的访问被禁止?我需要设置密码或ssl之类的东西 我怎样才能改变Web服务

我在IIS 6上部署了WCF Web服务。我现在部署它,创建一个网站并使用默认设置

我可以在我的Webbrowser中看到DNSService.svc?wsdl,这样我就可以访问这个站点。但,若我在VS项目中创建一个WebReference,并尝试运行WebService的一个方法,则程序将在SecurityNegotiationException中运行。Messagetext说Web服务无法对调用方进行身份验证。但为什么我的访问被禁止?我需要设置密码或ssl之类的东西

我怎样才能改变Web服务的行为,这样我就可以和他交谈了

<configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="DnsClient.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="UltraVNC" value="C:\Program Files (x86)\UltraVNC\vncviewer.edxe" />
    <add key="CustomerConfigsPath" value="D:\" />
  </appSettings>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IDNSService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="">
              <extendedProtectionPolicy policyEnforcement="Never" />
            </transport>
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
    <client>
      <endpoint address="http://hostnotshownhere/DNSService.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDNSService1"
        contract="ServiceReference1.IDNSService" name="WSHttpBinding_IDNSService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

问题在于绑定类型!wsHTTPBinding仅在域中工作。为了在互联网上使用,我必须像那样设置HTTPBinding

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IDNSService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm=""/>
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://MyServer/MyService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDNSService"
        contract="ServiceReference1.IDNSService" name="BasicHttpBinding_IDNSService" />
    </client>
  </system.serviceModel>


希望这能帮助别人

在哪个文件中,你能提供更多的描述,仅仅是相同的xml吗?