0

I'm trying to implement authorization into an existing WCF-service. To do that I following a Microsoft Pattern & practices tutorial.

At Step 5, the service class should derive from IService, however my existing service class does not and when I add : IService to my class Visual Studio doesn't recognize it.

How can I derive from the interface as described in the article?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.ServiceModel.Activation;

namespace MyCompanyNamespace.API.IISServiceHost
{
    [AspNetCompatibilityRequirements(RequirementsMode =     AspNetCompatibilityRequirementsMode.Required)]
    public class CompanyNameAPIService : IService //not recognized!
    {
        public ApproveitAPIService()
        {

        }
    }
}
David
  • 1,601
  • 3
  • 22
  • 33
  • 1
    plz check the namespace once. is the namespace where IService is in has been referenced? – Newton Sheikh Nov 04 '13 at 08:36
  • @NewtonSheikh. i don't know. I have no idea in which namespace I can find the interface "IService". – David Nov 04 '13 at 08:43
  • What IDE are you using? If it is Visual Studio, right click on IService and see if the resolve option is there. – David Pilkington Nov 04 '13 at 08:46
  • 1
    IService is the standard interface when you create a new WCF service. Check your code and see if there is something like an `ICompanyNameAPIService`. – Koen Nov 04 '13 at 08:49
  • Have you checked that your interface definition is public? If it's not set explicitly to public then you won't be able to inherit from it. – Andrew Nov 04 '13 at 08:50
  • @Koen. Could it be that I don't need to implement that interface? I'm just following the article so I don't actually know why I should make my class derive from that interface. – David Nov 04 '13 at 08:58
  • If you want to use WCF functionality then you need to create an interface to provide the methods you wish to expose. – Andrew Nov 04 '13 at 09:01
  • Can you find a class anywhere in your code called IService.cs? Looking at the tutorial it should be created when you create the WCF service. – Andrew Nov 04 '13 at 09:05
  • As @Andrew stated in his comment: you need to provide an interface when exposing things through WCF. Since this was an existing WCF service, it should have been there before. – Koen Nov 04 '13 at 09:07
  • @Andrew - technically, you do **not** have to create an interface to provide the methods for a WCF service. You can do it all in a class without an interface. Best practice is to use an interface, however. – Tim Nov 04 '13 at 09:36

1 Answers1

-1

From my point of view you have to Implement IService by yourself like in this Microsoft-Example.

Micha
  • 5,117
  • 8
  • 34
  • 47