2012-04-04 7 views
0

テーブルからすべてのレコードを取得する小さなWCFサービスを開発しました。それは以下のようになります。SQLテーブルを公開したWCF

IService1.cs

[ServiceContract] 
public interface IService1 
{ 
    List<badanieCis> GetRecords(); 
} 

Service1.svc.cs

public List<badanieCis> GetRecords() 
{ 
    przychodniaEntities dataContext = new przychodniaEntities(); 
    return dataContext.badanieCis.ToList(); 
} 

そして、私はメッセージを取得しています:サービスの追加に失敗しました。サービスメタデータにアクセスできない可能性があります。

<%@ ServiceHost Language="C#" Debug="true" 
    Service="Harvesting.Service.HarvestingService" CodeBehind="Service1.svc.cs" %> 

しかし、まだ何も:あなたのサービスがいくつかの研究は、このいずれかのSVCファイルにマークアップを変更した後、私が作ったどのようなメタデータ

を実行し、公開していることを確認してください。

マイweb.configファイル:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     </assemblies> 
    </compilation> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 
    <connectionStrings> 
    <add name="przychodniaEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DAREK-PC\SQLExpress;initial catalog=przychodnia;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
</configuration> 
+0

どこにホスティングしていますか? IIS?あなたの設定はどこですか? – Aliostad

+0

ただ開発サーバーでテストして、私は設定を追加しました – dargod

答えて

0

あなたが設定ファイルのサービス定義が欠落しています。あなたが設定を支援するために、このtoolを使用することができ

<services> 
    <service behaviorConfiguration="..." name="Service1 with namespace"> 
    <endpoint address="..." name="..." binding="wsHttpBinding" bindingConfiguration="...." contract="IService1 with unterface" /> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
<services> 
... 

:あなたのような何かを必要としています。

+0

私はWFCにかなり新しいと言う必要があります。代わりに "..."を置き、Web.configにこのコードを正確に挿入する場所を教えてください。 – dargod

+0

私はあなたを正しい方向に向けることができますが、あなたのためにあなたの仕事をすることはできません。あなたがWCFを使用している場合は、多くのことを学ぶ必要があります。 – Aliostad

+0

リンクをありがとうございます。残念ながら私のSDKではそのツールを見つけることができません。今私はそれについてgoogleする必要があります – dargod

関連する問題