Bmo
Bmo

Reputation: 1212

I have an interface implemented in an existing WCF service that I can't add a reference for

I have 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>

Absolutely nothing I've tried will expose the interface to the service. The only thing I can see is ASDService.DoWork. How does one implement other classes or interfaces inside a pre-existing service?

I've tried two services in the config, multiple endpoints. I've tried nesting the interface inside ASDService. I've read more tutorials and posts on here than I care to mention. As it sits I am getting the error

The contract name 'StatusSimulator.IScheduleTables' could not be found in the list of contracts implemented by the service 'ASDService'.

I'm baffled, out of ideas and am going to need professional help if this continues.

Upvotes: 4

Views: 1138

Answers (1)

marc_s
marc_s

Reputation: 754488

You shouldn't be mixing a service contract (defined on the concrete class ADsService) with the implementation of another service contract (IScheduleTables).

I would recommend that you have two distinct service contracts as interfaces (IASDService and IScheduleTables), and then one concrete class that implements both interfaces - something like this:

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...
      }
 }

As for resources: I would use these for starters:

Then there's a couple of good books - most notably Learning WCF by Michele Leroux Bustamante. She covers all the necessary topics, and in a very understandable and approachable way. This will teach you everything - basics, intermediate topics, security, transaction control and so forth - that you need to know to write high quality, useful WCF services.

Upvotes: 4

Related Questions