简体   繁体   中英

WCF service generated by WSCF.blue Service Error “implementation type is an interface or abstract class and no implementation object was provided”

I am using C# Visual Studio 2012 to create a wcf service.

I had the WSCF.blue tool generate the wsdl from the xsd-s. Then I generated the web service code using the same tool. WSCF.blue does not create a Service Contract and a Data Contract. It creates an interface and a .svc file that contains a class that implements the interface.

When generating the web service code I selected the option to create the abstract classes because I want to be able to keep the implementation of these classes in a separate file.

The abstract class looks like this:

 [KnownType(typeof(WebMobileImplementation))]     
public abstract class WebMobile : IWebMobile
{
      public abstract PutLocationsResponse PutLocations(PutLocationsRequest request);
}

The implementing class (in a different file) looks like this (for now):

 public class WebMobileImplementation : WebMobile
{
    public  override PutLocationsResponse PutLocations(PutLocationsRequest request)
    {
        PutLocationsResponse response = new PutLocationsResponse();
        return response;
    }
}

When trying to browse the service I get the message: " Service implementation type is an interface or abstract class and no implementation object was provided " I thought that adding the knowntype to the implementing class will do the trick but it seems that the implementation is not 'seen' when running the service. What else can I do to 'connect' them?

In WCF 4.0, you can define virtual service activation endpoints that map to your service types in Web.config. This makes it possible to activate WCF services without having to maintain physical .svc files.

<serviceHostingEnvironment>
  <serviceActivations>
    <add relativeAddress="WebMobile.svc" 
         service="WebMobileNamespace.WebMobileImplementation"/>
  </serviceActivations>
</serviceHostingEnvironment>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM