2011-09-14 21 views
0

IISで.svcページを参照するとこのエラーが発生します [ie。 http://localhost/PTSNew/PTNewService.svc]。このエラーを解決する方法を教えてください。また、baseAddress属性で指定されたURLが間違っていますか?ありがとう。WCFエラーが発生するのはなぜですか?

*

サービス 'PTSNew.PriceTestingServiceは' ゼロアプリケーション (非インフラストラクチャ)のエンドポイントを持っています。これは、アプリケーションに構成ファイル が見つからなかったか、またはサービス要素に一致するサービス要素 が構成ファイルに見つかりませんでした。または、 がサービス要素に定義されていないためです。

*

相続人は私のインターフェイスとはapp.configのxml:

namespace PTSNew 
{ 
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in App.config. 

     public class PriceTestingService : IPriceTesting, IDisposable 
} 

namespace PTSNew 
{ 
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in App.config. 

    [ServiceContract] 
    public interface IPriceTesting 
} 

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="ProviderBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
       receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" 
       bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
       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> 
    <services> 
     <service name="PTSNew.PriceTestingService" behaviorConfiguration="PTSNew.Service1Behavior"> 
     <host> 
      <baseAddresses> 
      <add baseAddress = "http://localhost:8731/Design_Time_Addresses/PTSNew/PriceTestingService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address ="" binding="basicHttpBinding" contract="PTSNew.IPriceTesting"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="PTSNew.Service1Behavior"> 
      <!-- 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="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

答えて

2

あなたはサービス要素

ため契約属性を書くのを忘れているようだ行ってくださいに例を表示する

+0

ありがとうoleksa.Iが問題のように私はすでにXMLで契約属性を持つ必要ノードを持っていると信じて: - ><エンドポイントアドレス= "" binding = "basicHttpBinding" contract = "PTSNew.IPriceTesting"> – Jimmy

0

IIS上でホストしている場合は、app.configではなくweb.configファイルに設定する必要があります。

IISでWCFをセルワイズでホストする場合、baseAddressは無視されます。ベースアドレスは、WCFサービスが配置されているWebサイトとWebアプリケーションアドレスによって決まります。

+0

ありがとうございました。私はこれを試してみます。そして、これがうまくいくならば、エラーメッセージはかなり誤解を招くものです! WCF地域で多くの誤解を招くようなもの]。 – Jimmy

0

サービス契約(IPriceTesting)では、どのような方法も公開されていません。インターフェイスにメソッドを追加し、OperationContract属性でそれらを飾る必要があります。その後、それらのメソッドをサービスクラス(PriceTestingService)に実装する必要があります。

例:

[ServiceContract] 
public interface IPriceTesting 
{ 
    [OperationContract] 
    decimal GetPrice(int productId); 
} 

そして

public class PriceTestingService : IPriceTesting 
{ 
    public decimal GetPrice(int productId) 
    { 
     //TODO: implement the method body 
     throw new NotImplementedException(); 
    } 
} 
+0

申し訳ありませんがリック、私はここで実装ロジック/その他の詳細を簡潔にスキップしました。私はすでにこれらのことを私のコードに追加しました。ありがとうございます。 – Jimmy

関連する問題