web-dev-qa-db-ja.com

WCF over SSL-404エラー

さて、私はここで非常に簡単なものを見逃しているに違いありません、私は何日もグーグルで、そこに数十の答えを見てきたので、ここSOで、私はこれをうまく動かせませんでした。プレーンHTTP経由で呼び出された場合、サービスは完全に正常に機能します。

これが設定です...ドメイン http://www.mydomain.com があります。電子商取引サイトを保護する場合と同じように、thawteからそのドメインにSSL証明書がインストールされています。それはすべて正常に動作し、https://www.mydomain.comにアクセスすれば正しく動作します。 Windows Server 2003 R2でVS2008、.NET 3.5サイトを実行しています。

ここで、Silverlight対応のWCFサービスをサイトに追加しました。これはSSLで通信したいものです。 https://www.mydomain.com/myservice.svcを参照すると、WSDLを説明する「期待通りにサービス)ページを作成しました。

svcutil.exe https:// ... 

EDIT:wsdlファイルのsvcutilに表示されるURLは、実際には適切なドメインではなく、Webサーバーの物理的なボックス名を指していることに気付きました。だから、このブログ投稿に示されている手順を経て、IISを使用してWebサイトのSecureBinding adsutilスクリプト:wsdlファイルに正しいSSLアドレスが表示されるようになりましたが、同じエラーが表示されます。

今、私はSilverlightアプリをそれに接続しようとしましたが、動作しません。非同期呼び出しの結果に例外を返し、「リモートサーバーがエラーを返しました:NotFound 。私が読んだ多くのブログは、テストWindowsアプリケーションを作成し、それからそれを参照しようとすることで、Silverlightの問題に絞り込むことについて話しました。 SSL経由でサービスにアクセスしようとする通常のWindowsアプリケーションは、次のような例外を受け取ります。

System.ServiceModel.EndpointNotFoundException: 
There was no endpoint listening at https://www.mydomain.com/mysubdir/myservice.svc that could accept the message. 
This is often caused by an incorrect address or SOAP action. 
See InnerException, if present, for more details. ---> 
System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

これは、HTTPSスキームを使用してWindowsアプリにサービス参照を明示的に追加し、すべてのメソッドを適切に取得してエディターのIntellisenseに表示するという事実にもかかわらずです。

これは、ユーザー側での明示的なログインを必要としないサービスであることに注意してください。 SOAPエンベロープでカスタムヘッダーを送信し、アプリからリクエストが送信されていることを確認します。捕食者が行をスニッフィングしてカスタムヘッダーを選択しないようにしたいだけです。

コードについては、愚かな小さな設定が間違っている必要がありますが、これは私が読んだすべてのことから、これはかなり簡単な練習になるはずです。

まず、私のサービスの分離コードクラスは、次の属性で装飾されています。

<ServiceBehavior(AddressFilterMode:=AddressFilterMode.Any)> 
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>

サーバー上のweb.configのServiceModelセクションは次のようになります。

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="basicHttpBinding">
                <security mode="Transport">
                    <transport clientCredentialType ="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="standingsBehavior">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        <baseAddressPrefixFilters>
            <add prefix="http://www.mydomain.com:80"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <services>
        <service behaviorConfiguration="standingsBehavior" name="lijslwebdata">
            <endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/>
            <!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
        </service>
    </services>
</system.serviceModel>

Windowsアプリケーションのapp.configのServiceModelセクションは次のようになります。

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_lijslwebdata" 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="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://www.mydomain.com/mysubdir/myservice.svc"
            binding="basicHttpBinding" 
            bindingConfiguration="BasicHttpBinding_lijslwebdata"
            contract="xdata.lijslwebdata" name="BasicHttpBinding_lijslwebdata" />
    </client>
</system.serviceModel>
38
eidylon

さて、私は明らかに問題を修正しました、そしてなぜ/どのように私は全く見当がつきません。

これが私がしたことです。

  • 真新しいEMPTY Silverlight対応WCFサービスを追加しました
  • 次に、両方のサービスを反映するようにweb.configを更新しました
  • 次に、名前を除いて、最初のサービスに関するすべてを2番目のサービスに文字通りコピーして貼り付けました。

なぜこれが修正されたのか、まったくわからない。

誰のためのFWIWでも、2番目のサービスを含む新しいweb.config ServiceModelセクションがあります...

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="basicHttpBinding">
            </binding>
            <binding name="basicHttpsBinding">
                <security mode="Transport">
                    <transport clientCredentialType ="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="standingsBehavior">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        <baseAddressPrefixFilters>
            <add prefix="http://www.mydomain.com/"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <services>
        <service behaviorConfiguration="standingsBehavior" name="lijslwebdata">
            <endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
        <service behaviorConfiguration="standingsBehavior" name="sslwebdata">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="sslwebdata"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>
1
eidylon

私も同じ問題を抱えていました。あなたの投稿は私が問題が何であるかを理解するのに役立ちました。これが私のサービスモデルセクションです。キーがhttpsGetEnabledであり、bindingconfigurationが設定されていることを発見しました。これが役立つことを願っています。

<system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="RequestImageBehavior">
                    <serviceMetadata **httpsGetEnabled**="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                  <dataContractSerializer maxItemsInObjectGraph="1073741824" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="RequestImageBehavior" name="RequestImage">
                <endpoint address="" 
                          binding="wsHttpBinding" 
                          **bindingConfiguration**="HttpsBinding"
                          contract="IRequestImage">
                </endpoint>
                <endpoint address="mex" 
                          binding="mexHttpBinding" 
                          contract="IMetadataExchange" />
            </service>
        </services>
      <bindings>
        **<wsHttpBinding>
          <binding name="HttpsBinding">
            <security mode="Transport">
              <transport clientCredentialType="None"/>
            </security>
          </binding>
        </wsHttpBinding>**
      </bindings>
    </system.serviceModel>
27
user209884

私は最近これを扱っていたので、微調整を追加したいと思います。上記の手順に従えば、サービスをHTTPSで動作させることができますが、HTTPとHTTPSの両方で同時に動作することはできません。これを行うには、次のように各プロトコルに1つずつ、2つのエンドポイント構成ノードが必要です。

 <service name="MyCompany.MyService" >
    <endpoint address="" behaviorConfiguration="AspNetAjaxBehavior"
      binding="webHttpBinding" contract="MyCompany.MyService" bindingConfiguration="sslBinding" />
    <endpoint address="" behaviorConfiguration="AspNetAjaxBehavior"
      binding="webHttpBinding" contract="MyCompany.MyService" />
  </service>

(私のコードベースから取得し、必要に応じてbehaviourConfigurationとバインディングを調整します)

11
John Ketchpaw

私はこれに数時間を費やしましたが、私の問題はサービス名でした

<services>
      <service name="TimberMill.Web.Data.LogReceiverService">
        <endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding"
                     contract="NLog.LogReceiverService.ILogReceiverServer" />
      </service>
    </services>

* .svcファイルの同様のエントリと正確に一致する必要がありました。

<%@ ServiceHost 
    Language="C#" 
    Debug="true" 
    Service="TimberMill.Web.Data.LogReceiverService, TimberMill.Web"
    Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf"
    CodeBehind="LogReceiverService.svc.cs" 
%>

Autofacの使用に関連しているかどうかはわかりません。それはすべて、単純なHTTPで正常に機能していました。ただし、HTTPSでは失敗しました。

そうだと思うので、WCF-Configの神々を怒らせて、私の設定が再び壊れないように、今より詳細にテストすることで何も邪魔したくない。 YMMV。

8
fiat

私の場合、これらの答えはどれも役に立たなかった。

代わりに、 重複する<binding>セクションにname属性が設定されていない

ここに私のサービスのweb.configファイルの適切なセクションのダンプがあります:

<behaviors>
    <serviceBehaviors>
        <behavior name="ServiceBehaviour">
            <serviceMetadata 
                httpsGetEnabled="true" 
                httpsGetUrl="RemoteSyncService.svc"
                httpGetBindingConfiguration="bindingConfig" />
            <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
            <serviceMetadata 
                httpsGetEnabled="true" 
                httpsGetUrl="RemoteSyncService.svc" />
            <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
    </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>
    <binding name="bindingConfig" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
        <security mode="Transport">
          <transport clientCredentialType="None"/>
        </security>
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
    </binding>

    <!-- Add binding with EMPTY/MISSING name, see https://forums.iis.net/t/1178173.aspx -->
    <binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
        <security mode="Transport">
          <transport clientCredentialType="None"/>
        </security>
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
    </binding>
  </basicHttpBinding>
</bindings>

これがいつか誰かに役立つことを願っています。

3
Uwe Keim

私は同じ問題を抱えており、この問題を解決するために1日を費やしました。最後に、HTTPSアクセスの場合、以下の構成でうまくいきました。

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="basicHttpBinding">
            </binding>
            <binding name="basicHttpsBinding">
                <security mode="Transport">
                    <transport clientCredentialType ="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="standingsBehavior">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        <baseAddressPrefixFilters>
            <add prefix="http://www.mydomain.com/"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <services>
        <service behaviorConfiguration="standingsBehavior" name="lijslwebdata">
            <endpoint address="" binding="basicHttpBinding" contract="lijslwebdata"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
        <service behaviorConfiguration="standingsBehavior" name="sslwebdata">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="sslwebdata"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>
2
Murali

いくつかの答えから、2つのエンドポイントを含むようにweb.configを再構成することになりました。この次のWeb.configになりました。

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding">
        </binding>
        <binding name="basicHttpsBinding">
          <security mode="Transport">
            <transport clientCredentialType ="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="standingsBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
      <baseAddressPrefixFilters>
        <add prefix="http://www.myhost.com"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

    <services>
      <service behaviorConfiguration="standingsBehavior" name="NameSpace.ClassName">
        <endpoint address="" binding="basicHttpBinding" contract="NameSpace.ContractInterfaceName"/>
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="NameSpace.ContractInterfaceName"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>
1
Harald Lund

すべてが非常に有効であるようで、明白な間違いはまったくありません...

ただ一つの観察/質問:* .svcファイルはどこにありますか??

エラーメッセージには次のように表示されます。

 https://www.mydomain.com/myservice.svc 

* .svcファイルは実際にサイトのトップレベル仮想ディレクトリにありますか?

通常、*。svcファイルはIISの仮想ディレクトリ内にあるため、アドレスは次のようになります。

 https://www.mydomain.com/YourVirtualDirectory/myservice.svc 

もちろん、ASP.NETアプリとWCFサービス* .svcファイルをIIS-のルートに展開できますが、私の経験ではあまり一般的ではありません。

確認することはただ.....

マーク

1
marc_s

BasicHttpBinding構成に「basicHttpBinding」という名前を付けたが、bindingConfiguration = "basicHttpBinding"を使用してタグ内のその構成を参照しなかったため、以前は機能しませんでした。

別のサービス構成を追加することで機能した変更では、ノードを含むバインディング構成を参照していたため、機能します。

0
Huzaifa Tapal

OPと同じ404エラーが発生しているかどうかを確認するだけです。私は多くのことをいじりましたが、最終的に解決策は、サービスweb.configに名前空間を追加するだけでした。

したがって、古いServiceFooとIServiceFooは機能しませんでした。

  <services>
     <service behaviorConfiguration="quuxBehavior" name="ServiceFoo">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="IServiceFoo"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
     </service>
  </services>

ただし、ネームスペース(ProjectBar)を追加すると、DID work:

  <services>
     <service behaviorConfiguration="quuxBehavior" name="ProjectBar.ServiceFoo">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="ProjectBar.IServiceFoo"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
     </service>
  </services>
0
Matthew Lowe