0

Currently I'm building a central place to do some common tasks, which a bunch of projects should use and it would be extremely nice to have this (mostly for convenience, I'll admit):

enter image description here

I just can't seem to do that. I've tried implementing multiple interfaces, but that doesn't work the way I want. It exposes too much in the same place. I have a pseudo thing going on right now where I have three services, but on three different addresses (/ReportingService.svc, /QueueService.scv, and /TicketService.svc) and thus the above doesn't happen (ideally just one /Services.svc).

The way the dialog is constructed seems to support this way of exposing services (namely it says "1 service(s) found at[...]"), but I just can't find a way to do it.

I suppose this could be helpful, but I haven't been able to make it work either. I just get a 404 when trying to open the listenUri.

Does anyone have any good ideas?

Community
  • 1
  • 1
Heki
  • 926
  • 2
  • 15
  • 34

1 Answers1

0

You need to create your methods in the interface (and obviously implement those methods in your service class).

[ServiceContract]
public interface IService
{
    [OperationContract]
    string method1(int code);

    [OperationContract]
    int method2(String id);
}

So, now you have just one service and multiple methods inside of it.

Or if you want to keep your methods organized, you could include services in your Web.config file.

<services>
    <service name="ServicioWeb.IService1">

    <endpoint binding="webHttpBinding" 
              contract="ServicioWeb.IService1"
              behaviorConfiguration="WebBehavior"
              />        
    </service>
    <service name="ServicioWeb.IService2">

    <endpoint binding="webHttpBinding" 
              contract="ServicioWeb.IService2"
              behaviorConfiguration="WebBehavior"
              />        
     </service>
</services>

And your URL would change a bit. Something like this: http://localhost:8080/Service1.svc/... http://localhost:8080/Service2.svc/...

Freddy Hdz
  • 137
  • 6
  • Yes, but I need this one level higher. Lets say that each of the services have 5 methods/operations each. The approach that I could use based on your answer is to pile them all up in one class (togeather or in partials). This I already have worked around by making three seperate services. What I want is to have those three listed on the same URL, as per my beautiful image :D – Heki Dec 13 '16 at 14:44
  • you could add _services_ to your Web.config file. Updated my answer – Freddy Hdz Dec 13 '16 at 15:38
  • 1
    Thanks for the effort, but your edit describes _exactly_ what I already have; different URLs for each service. I want all of them included in the same URL, separated the way I've described in the question. – Heki Dec 13 '16 at 15:39
  • Oh well. You could use endpoints with different addresses. It would be like – Freddy Hdz Dec 13 '16 at 16:10
  • /Service.svc/svc1/method1... /Service.svc/svc2/method2.. etc – Freddy Hdz Dec 13 '16 at 16:11
  • I know, but it still does not answer my question; I specifically want to avoid what you suggest. – Heki Dec 14 '16 at 10:04