客户端身份验证方案“匿名”禁止HTTP请求。尝试添加服务引用时

时间:2012-02-27 15:25:00

标签: wcf visual-studio-2010 windows-server-2008 wcf-client

我有一个在主机中配置的WCF服务,如下所示:

        Uri baseAddress = new Uri("http://10.94.8.27:8989/MyServiceSoap");

        // Create the ServiceHost.
        using (ServiceHost host = new ServiceHost(typeof(MyServiceSoapService), baseAddress))
        {
            // Enable metadata publishing.
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
            host.Description.Behaviors.Add(smb);

当主机在Win7机器上时,我可以从同一台或另一台Win7机器上的客户端添加对它的引用,但不能在Win Server 2008机器上添加引用。
当主机在Win Server 2008计算机上时 - 完全相同(适用于Win7计算机上的客户端,对Win Server 2008计算机上的客户端不起作用)。
这意味着,我无法向客户端在Win 2008计算机上的主机位置添加服务引用。 我可以在系统/服务/主机配置中做些什么改变吗?

提前谢谢你!

服务库中的app config:

<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="MyServiceLib.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/MyServiceLib/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="soap" binding="basicHttpBinding" contract="MyServiceLib.IService1"/> 
        <endpoint address ="" binding="wsHttpBinding" contract="MyServiceLib.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

0 个答案:

没有答案