1

サービスを公開して Windows 認証を使用させようとしていますが、公開しようとしてもエラーが発生するため、ユーザー名の入力を求めるプロンプトが表示されません。

これは私のエラーです:

[ArgumentException: ServiceHost only supports class service types.]
   System.ServiceModel.Description.ServiceDescription.GetService(Type serviceType) +16602430
   System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts) +80
   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +174
   System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +475
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +43
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +530
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivationException: The service '/subservice/ISubService.svc' cannot be activated due to an exception during compilation.  The exception message is: ServiceHost only supports class service types..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +901424
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178638
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

これについて何百回も調査しましたが、サービスを公開した経験はほとんどありません。彼らが構築された後、私は彼らと協力してきました.

これは、問題なく公開されている別の web.config から変更した私の web.config です。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="log4net.Internal.Debug" value="true" />
  </appSettings>
  <system.web>
    <compilation targetFramework="4.0" debug="true">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="DefaultCache" duration="60" varyByParam="none" />
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpEndpointBinding">
          <security mode="None">
            <!-- Basic <security mode="Transport"> -->
            <!-- To use Basic auth, just comment Windows and use this, but you need to configure basic in IIS as well -->
            <!-- <transport clientCredentialType="Basic" /> -->
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="default">
          <security mode="None">
            <!-- Basic <security mode="Transport"> -->
            <!-- To use Basic auth, just comment Windows and use this -->
            <!-- <transport clientCredentialType="Basic" /> -->
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <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="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service name="subservice.ISubService">
        <endpoint binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" contract="subservice.ISubService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="rest" binding="webHttpBinding" bindingConfiguration="default" behaviorConfiguration="restBehavior" contract="subservice.ISubService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <httpProtocol>
      <customHeaders>
        <add name="p3p" value="CP=&quot;CAO PSA OUR&quot;" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>

</configuration>

web.release.config には何もありません:

<?xml version="1.0"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>

</configuration>

これは私のアプリケーションがどのように見えるかです:

ここに画像の説明を入力

誰かが私が間違っていることを見ていますか?

4

1 に答える 1

6

このエラーは、サービス インターフェイスを実装するクラス タイプの代わりに、インターフェイス タイプを使用してホストを構築していることを示していますISubService

例えば。

ServiceHost host = new ServiceHost(
                       typeof(subservice.ISubService), new Uri("someuri"));

これがあなたの使用法である場合は、実装されたサービス クラス タイプを使用するように変更します。ISubService

ServiceHost host = new ServiceHost(
                       typeof(subservice.SubService), new Uri("someuri"));

.svc でサービスを構成する場合:

<%@ServiceHost Service="subservice.SubService"%>

また、構成ファイルで、サービス名をサービス コントラクトではなくサービスに変更します。

   <services>
          <service name="subservice.SubService">
          ...
于 2013-02-10T18:26:52.837 に答える