1

リモート サーバーでホストされている WCF サービスを使用する WinForms アプリケーションがあります。アプリケーションを実行すると、データが実行されてロードされますが、30 秒以上実行すると次のように表示されますMessageSecurityException

セキュリティ プロセッサは、メッセージ内にセキュリティ ヘッダーを見つけることができませんでした。これは、メッセージがセキュリティで保護されていない障害であるか、通信する当事者間にバインディングの不一致があるためである可能性があります。これは、サービスがセキュリティ用に構成されていて、クライアントがセキュリティを使用していない場合に発生する可能性があります。

私のサービス構成は次のとおりです。

<system.serviceModel>
    <!-- change -->
    <bindings>
      <customBinding>
        <binding name="Wrabind" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00">
          <textMessageEncoding/>
          <security authenticationMode="SecureConversation" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="00:30:00" />
            <localServiceSettings maxClockSkew="00:30:00" />
            <secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
              <localClientSettings maxClockSkew="00:30:00" />
              <localServiceSettings maxClockSkew="00:30:00" />
            </secureConversationBootstrap>
          </security>
          <httpTransport maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" maxBufferSize="20000000" keepAliveEnabled="false" />
        </binding>
      </customBinding>
    </bindings>
    <!-- change -->
    <services>
      <service behaviorConfiguration="WServiceCoreService.Service1Behavior" name="WServiceCoreService.Service1">
        <endpoint address="http://subdomain.domain.com/service1.svc" binding="customBinding" bindingConfiguration="Wrabind" contract="WServiceCoreService.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WServiceCoreService.Service1Behavior">
          <serviceThrottling
maxConcurrentCalls="200"
maxConcurrentSessions="200"
maxConcurrentInstances="200" />
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="false" />

          <!-- 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>
    </behaviors>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://subdomain.domain.com/" />
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>


  </system.serviceModel>

私のWinFormsクライアント構成は次のとおりです。

<system.serviceModel>

    <bindings>
      <wsHttpBinding>
        <binding name="CustomBinding_IService1"  maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00">
          <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />

        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://subdomain.domain.com/service1.svc" binding="wsHttpBinding"
        bindingConfiguration="CustomBinding_IService1" contract="WCoreService.IService1"
        name="CustomBinding_IService1">
        <identity>
          <userPrincipalName value="WIN-489ESBTC0A0\servewranglein_web" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

この構成のエラーを予測することはできません。できるだけ早くこれを解決するのを手伝ってください。

更新:.NET 4.0 を使用しています

4

3 に答える 3

1

これを試してください(ホストとクライアントの両方):

    <binding name="XXXXX">
      <security mode="None" >
        <transport clientCredentialType="None" />
        <message  establishSecurityContext="False" />
      </security>
    </binding>
于 2013-10-03T15:18:07.880 に答える
1

私の場合、ホスト構成ファイルの AudienceUris タグにサービスを追加すると、同じ例外で問題が修正されました。

<system.identityModel>
...
    <identityConfiguration>
    ...
        <audienceUris>
            <add value="serviceName.svc" />
        </audienceUris>
    ...
    </identityConfiguration>
...
</system.identityModel>
于 2014-12-11T15:44:54.233 に答える
1

クライアント側で enableUnsecuredResponse を true に設定してみて、うまくいくかどうか教えてください。詳細については、 http://support.microsoft.com/kb/971493も参照してください。

于 2013-10-03T12:56:17.107 に答える