A way to unify calls in WCF Service?

0

Greetings to all. I currently have a WCF Service Application running on IIS with many services, with each new service I need a new update and a new client side reference. As I am new to WCF, would you like to know if it is possible to centralize all these services in a single service? I know the question may be very relative, because this depends a lot on what each method returns and such, but I accept any suggestion, because I wanted to have only one service and one method and everything goes through the same channel, is it possible? Can I have loss of requests or is a queue generated? Sorry if I did not express myself in a correct or technical way, like I said I'm new, thank you!

Paulo Balbino

    
asked by anonymous 01.07.2014 / 19:04

2 answers

1

Paul,

If the main goal is to call methods without updating the client, following the example, I can suggest the following:

    enum Metodos { MetodoA, MetodoB };

    [ServiceContract]
    public interface IMeuServico
    {
        string MetodoA();
        string MetodoB();

        [OperationContract]
        string MetodoPrincipal(Metodos metodo);
    }

and the class that implements the above interface:

public class Service1 : IMeuServico
{
    public string MetodoA()
    {
        throw new NotImplementedException();
    }
    public string MetodoB()
    {
        throw new NotImplementedException();
    }
    public object MetodoPrincipal(Metodos metodo)
    {
        switch (metodo)
        {
            case Metodos.MetodoA: return MetodoA();
            case Metodos.MetodoB: return MetodoB();

            default:
                return null;
        }
    }
}
    
01.07.2014 / 20:25
0

You can centralize all these services into one service. You can have a WCF service with all methods.

[ServiceContract]
public interface IMeuServico
{
    //Disponibilizar todos os métodos que deseja expor no seu serviço
    [OperationContract]
    string MetodoA();

    [OperationContract]
    string MetodoB();
}

However, if you need to create a new method, you will still need to update the reference that the client has of your service so that it can see this new method and use it.

Try to create services based on a feature. You'll get less code, easier maintenance.

Example:

[ServiceContract]
public interface IMeuServicoFuncionalidadeA
{
    //Disponibilizar todos os métodos que deseja expor no seu serviço
    [OperationContract]
    string MetodoA();
}

[ServiceContract]
public interface IMeuServicoFuncionalidadeB
{
    //Disponibilizar todos os métodos que deseja expor no seu serviço
    [OperationContract]
   string MetodoB();
}

About: " ... wanted to have only one service and one method and everything goes through the same channel, is it possible? Can I have requests lost or is a queue generated? "

With all methods in only one service, a yes queue can be generated. For example, if the management mode of your instance is PerSession , the service will be able to serve only a single thread and so the other threads will have to wait for the release to be processed.

For details on managing instances, take a look at this link .

    
01.07.2014 / 19:24