2012-04-15 11 views
1

をしようとしたときに見つかりません - が見つかりませんでした あなたが探しているリソースが削除されているが、その名前が変更された、または現在利用でき。HTTPエラー404.0 - 私はこの</p> <p>HTTPエラー404.0取得していますローカルWCFにアクセスするために

私のブラウザからサービスにアクセスしようとしています。ここに私の設定です。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 

     <services> 
      <!-- Note: the service name must match the configuration name for the service implementation. --> 
      <service name="WcfServiceLibrary.Service1" behaviorConfiguration="MyServiceTypeBehaviors" > 
       <!-- Add the following endpoint. --> 
       <!-- Note: your service must have an http base address to add this endpoint. --> 
       <endpoint contract="WcfServiceLibrary.Service1" binding="basicHttpBinding" address="http://localhost/service1" /> 
       <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="http://localhost/service1/mex" /> 
      </service> 
     </services> 

     <behaviors> 
      <serviceBehaviors> 
       <behavior name="MyServiceTypeBehaviors" > 
        <!-- Add the following element to your service behavior configuration. --> 
        <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/service1" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 

    </system.serviceModel> 

</configuration> 

私は、Webブラウザでhttp://localhost/service1を入力すると、私は404を得る。しかし、私は下のApp.configファイルを削除し、ちょうどsimpley

string serviceUrl = "http://localhost/service1"; 
Uri uri = new Uri(serviceUrl); 
host = new ServiceHost(typeof(Service1), uri); 
host.Open(); 

の背後にあるコードでこれを行う場合は、すべてがうまく機能します.. 。 何か案は?シンプルだと思われる。

+0

IISまたはSelfでこれをホストしようとしていますか? – Martin

+0

セルフホスト。私はWindowsフォームアプリケーション – stack

+0

を作成しました。 – stack

答えて

3

私はあなたのサービスの下で、ホスト要素が欠落していると思う:

<service name="WcfServiceLibrary2.Service1"> 
    <host> 
     <baseAddresses> 
      <add baseAddress = "http://localhost/service1" /> 
     </baseAddresses> 
    </host> 
    <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary2.IService1"> 
     <identity> 
      <dns value="localhost"/> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
</service> 

サービスのホストは、URLを必要としません。

static void Main(string[] args) 
    { 
     var host = new ServiceHost(typeof(Service1)); 
     host.Open(); 

     Console.WriteLine("Host running"); 
     Console.ReadLine(); 
    } 
+0

ありがとうございました。しかし、余分な理由として、私はmexをブラウザでhttp:// localhost/service1/mexで見ることができませんでしたか? – stack

+0

なぜこれがダウン投票されたのか不思議ですか? –

0

ブラウザでhttp://localhost/service1?Wsdlを表示することができますが、MEXのみ追加サービス参照またはWCFTestClientで動作します(C:\プログラムファイルのMicrosoftのVisual Studio 10.0 \ Common7 \ IDE \(x86の))は、あなたが悪いHTTPを取得しますので、リクエストのエラーは、ブラウザのHTTP GETリクエストが発行され、メッセージの内容がHTTPヘッダーにあり、本文が空の場合に発生します。

これは、まさにWCF mexHttpBindingが不平を言っていることです。

+0

その情報をありがとう... – stack

関連する問題