2

我通过无文件激活在 XP 上的 IIS 中托管了一项服务。当没有为 IIS 启用 SSL 端口时,服务启动正常,但启用 SSL 端口时,我收到错误消息:

System.ServiceModel.ServiceActivationException:由于编译期间出现异常,无法激活服务“/SkillsPrototype.Web/services/Linkage.svc”。异常消息是:绑定实例已关联到侦听 URI ' http://rcollet.hsb-corp.hsb.com/SkillsPrototype.Web/Services/Linkage.svc '。如果两个端点想要共享同一个 ListenUri,它们也必须共享同一个绑定对象实例。两个冲突的端点要么在 AddServiceEndpoint() 调用中指定,要么在配置文件中指定,要么在 AddServiceEndpoint() 和 config 的组合中指定。. ---> System.InvalidOperationException: 绑定实例已经关联到监听 URI ' http://rcollet.hsb-corp.hsb.com/SkillsPrototype.Web/Services/Linkage.svc'。如果两个端点想要共享同一个 ListenUri,它们也必须共享同一个绑定对象实例。两个冲突的端点要么在 AddServiceEndpoint() 调用中指定,要么在配置文件中指定,要么在 AddServiceEndpoint() 和 config 的组合中指定。

我的服务模型配置是

  <system.serviceModel>
    <diagnostics wmiProviderEnabled="true">
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
    </diagnostics>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
      </webHttpEndpoint>
    </standardEndpoints>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding>
           <security mode="None">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
    </protocolMapping>
    <services>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false">
      <serviceActivations>
        <clear/>
        <add factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" service="SkillsPrototype.ServiceModel.Linkage" relativeAddress="~/Services/Linkage.svc"/>
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>

当您查看 svclog 文件时,会在启用 SSL 时返回两个基地址,一个用于 http,一个用于 https。我怀疑这是问题的一部分,但我不知道如何解决它。

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
  <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
    <EventID>524333</EventID>
    <Type>3</Type>
    <SubType Name="Information">0</SubType>
    <Level>8</Level>
    <TimeCreated SystemTime="2010-06-16T17:40:55.8168605Z" />
    <Source Name="System.ServiceModel" />
    <Correlation ActivityID="{95927f9a-fa90-46f4-af8b-721322a87aaa}" />
    <Execution ProcessName="aspnet_wp" ProcessID="1888" ThreadID="5" />
    <Channel/>
    <Computer>RCOLLET</Computer>
  </System>
  <ApplicationData>
    <TraceData>
      <DataItem>
        <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
          <TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.ServiceHostBaseAddresses.aspx</TraceIdentifier>
          <Description>ServiceHost base addresses.</Description>
          <AppDomain>/LM/w3svc/1/ROOT/SkillsPrototype.Web-1-129211836532542949</AppDomain>
          <Source>System.ServiceModel.WebScriptServiceHost/49153359</Source>
          <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/CollectionTraceRecord">
            <BaseAddresses>
              <Address>http://rcollet.hsb-corp.hsb.com/SkillsPrototype.Web/Services/Linkage.svc</Address>
              <Address>https://rcollet.hsb-corp.hsb.com/SkillsPrototype.Web/Services/Linkage.svc</Address>
            </BaseAddresses>
          </ExtendedData>
        </TraceRecord>
      </DataItem>
    </TraceData>
  </ApplicationData>
</E2ETraceEvent>

由于帖子的字符限制,我无法发布完整的服务日志。

4

1 回答 1

3

在花费数小时后,我在发布后不久解决了这个问题。

该问题似乎与使用 WebScriptServiceHostFactory 有关。相反,我创建了一个带有 kind 属性的服务条目,现在它可以工作了。

这是更正后的配置

  <system.serviceModel>
    <diagnostics wmiProviderEnabled="true">
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
    </diagnostics>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
      </webHttpEndpoint>      
    </standardEndpoints>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <!--Default settings for the webHttpBinding-->
        <binding>
           <security mode="None">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
    </protocolMapping>
    <services>
      <service name="SkillsPrototype.ServiceModel.Linkage">
        <endpoint
          kind="webScriptEndpoint"
          contract="SkillsPrototype.ServiceModel.ILinkage"/>
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false">
      <serviceActivations>
        <clear/>
        <add service="SkillsPrototype.ServiceModel.Linkage" relativeAddress="~/Services/Linkage.svc"/>
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>
于 2010-06-16T20:27:45.747 回答