0

I have a web service created by me, which I include in a .NET console project successfully, while it is impossible to include to a web site project. Each time I add a web reference, my assistant does not find the service locally, but if I introduce the web URL, it is there. Besides, automatically generated classes are totally different in the console application from those generated in web site application.

The web service is a WFC service, and it has callback functions, so I need some interface like IServiceLectorTarjetasSharpCallback, that I cannot find when I add the reference to my web site.

I am using VS 2015.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
user2413439
  • 23
  • 1
  • 6

1 Answers1

0

I would avoid code generation when possible. If you want, try this:

  1. Create contract assembly to define service interface and contract:

[ServiceContract] public interface IService { [OperationContract] CustomResponse Test(string test); } public class CustomResponse { }

  1. Import contract dll and implement the service normally in service project:

public class ServiceImplementation : IService { public CustomResponse Test(string test) { return new CustomResponse(); } }

  1. Implement Client in client assembly referencing contract as well:

public interface IServiceClient { CustomResponse Test(string test); } public class ServiceClient : ClientBase< IService>, IServiceClient { public CustomResponse Test(string test) { return Channel.Test(test); } }

  1. Consume client:

IServiceClient client = new ServiceClient(); //or some DI var result = client.Test("Test");

Miłosz Wierzbicki
  • 2,082
  • 1
  • 13
  • 15