0

I have a simple WCF service running on a server machine.

Unit Test calling the service:

[TestMethod]
public void CreateLabelManagerTestMethod()
{
    // Arrange
    var client = new PrintServiceClient();

    // Act
    var manager = client.CreateLabelManager() as ILabelManager;

   // Assert
   Assert.IsNotNull(manager);
}

I am getting an exception:

{"An error occurred while receiving the HTTP response to [myservice.svc]. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."}

[ServiceContract]
public interface IPrintService
{
    [OperationContract]
    ILabelManager CreateLabelManager();
}

public class PrintService : IPrintService
{
    public ILabelManager CreateLabelManager()
    {
        return new LabelManager();
    }
}

[DataContract]
public class LabelManager : ILabelManager
{        
    public ILabel CreateLabel(string templateFullFileName)
    {
        return new Label(templateFullFileName);
    }
}

[DataContract]
class Label : ILabel, IEnumerable<IField>, IDisposable
{
    public Label(string templateFullFileName)
    {
        this.TemplateFullFileName = templateFullFileName;          
    } 
    [DataMember]
    public string TemplateFullFileName { get; set;} //add set for serialization
}
ehh
  • 3,412
  • 7
  • 43
  • 91
  • 2
    WCF is not Remoting nor COM. You're not sending "live" objects over the wire, you're sending data (the object's properties). What you appear to be designing is not going to work over a web service. You will not be able to do `manager.CreateLabel()` on the client. That being said, read the exception. An error is occurring, probably due to parameterless constructors missing. See [How to turn on WCF tracing?](http://stackoverflow.com/questions/4271517/how-to-turn-on-wcf-tracing) and read the logs. – CodeCaster Dec 22 '16 at 13:47
  • I had that problem but I fixed the problem by installing visual studio 2017. It will automatically install latest version of net core if you choose that option in visual studio setup and also if you are using .net core. – Houtan May 16 '17 at 19:02

0 Answers0