4

私は持っていますASDService.svc

 namespace StatusSimulator
 {
      [ServiceContract]
      public class ASDService
      {
           [OperationContract]
           public void DoWork()
      }

      [ServiceContract]
      public interface IScheduleTables
      {
            [OperatonContract]
            string getTable(string l, int r, int c)
            [OperatonContract]
            string getTable(string test)
            [OperatonContract]
            string createTable(List<string> lst, int r, int bal)
      }

      public class ScheduleTables:IScheduleTables
      {
               //Interface Implementation
      }
 }

web.config:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NewBehavior0">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="NewBinding0" />
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="NewBehavior0" name="StatusSimulator.ASDService">
        <endpoint address="http://localhost:2405/ASDService.svc" binding="basicHttpBinding"
          bindingConfiguration="NewBinding0" name="ASDEndpoint" contract="StatusSimulator.ASDService" />
        <endpoint address="http://localhost:2405/ASDService.svc" binding ="basicHttpBinding"
          bindingConfiguration="NewBinding0" name="ScheduleTableEndPoint" contract="StatusSimulator.IScheduleTables" />
      </service>
    </services>
  </system.serviceModel>

私が試したことは絶対に何もありません。インターフェイスをサービスに公開します。私が見ることができる唯一のものはASDService.DoWork. 既存のサービス内に他のクラスまたはインターフェースをどのように実装しますか?

構成で 2 つのサービス、複数のエンドポイントを試しました。ASDService 内でインターフェイスをネストしてみました。ここで言及したいよりも多くのチュートリアルと投稿を読みました。座っているとエラーが発生します

コントラクト名「StatusSimulator.IScheduleTables」は、サービス「ASDService」によって実装されたコントラクトのリストに見つかりませんでした。

私は当惑しており、アイデアがなく、これが続く場合は専門家の助けが必要になります.

4

1 に答える 1

4

ADsServiceサービス コントラクト (具象クラスで定義) と別のサービス コントラクト ( ) の実装を混在させるべきではありませんIScheduleTables

インターフェイスとして2 つの異なるサービス コントラクト(IASDServiceおよびIScheduleTables) を用意し、次に両方のインターフェイスを実装する1 つの具象クラスを用意することをお勧めします。たとえば、次のようになります。

namespace StatusSimulator
{
      [ServiceContract]
      public interface IASDService
      {
           [OperationContract]
           public void DoWork()
      }

      [ServiceContract]
      public interface IScheduleTables
      {
            [OperatonContract]
            string getTable(string l, int r, int c)
            [OperatonContract]
            string getTable(string test)
            [OperatonContract]
            string createTable(List<string> lst, int r, int bal)
      }

      public class ServiceImplementation : IADSService, IScheduleTables
      {
         // implement both interfaces here...
      }
 }

リソースについては、まずこれらを使用します。

次に、2 冊の優れた本があります。最も注目すべきは、Michele Leroux Bustamante によるLearning WCFです。彼女は必要なすべてのトピックを、非常に理解しやすく親しみやすい方法でカバーしています。これにより、高品質で有用な WCF サービスを作成するために知っておく必要がある基本事項、中級トピック、セキュリティ、トランザクション制御など、すべてを学ぶことができます。

于 2013-04-19T12:11:26.707 に答える