Class with several referenced wcf services

1

I would like to know if the following is possible:

I want to create a class that references several ws and that in the class has the properties that in the majority of the services use the same variables ...

public class wsProcedimientos
{
 //********  Propiedades  *****************
    public string Usuario { get; set; }

    public string PwdService { get; set; }

    public FileStream ArchivoAid { get; set; }

    public string NumeroDocumento { get; set; }

  ///....etc
 //********  Metodos  *****************
    void wsReferenciado1()...
//*** Aca instanciar ws1 y realizar acciones

    void wsReferenciado2(string User, string pwdService)...
//*** Aca instanciar ws2 y realizar acciones

    void wsReferenciado3(string User, string pwdService, FileStream archivoAid )...
//*** Aca instanciar ws3 y realizar acciones

    void wsReferenciado4(string User, string pwdService, NumeroDocumento)...
//*** Aca instanciar ws4 y realizar acciones

 }

When instantiating this class, the object must have the behavior that only the service I am using (depending on the case) takes, for example:

 wsProcedimientos wsP = new wsProcedimientos();
 var response = wsP.wsReferenciado2(strUsr, strPwd)

As a reference several ws is it probable that a load of the ws that is required to be used at the time of instantiation will be made? I'm new with wcf

    
asked by ger 22.11.2018 в 20:28
source

1 answer

0

You have already solved the calls to the services, now you have to restructure your code only. username and password pass to the constructor with an overload without arguments.

public class wsProcedimientos{
    public String userName;
    public String password;
    public wsProcedimientos(){};
    public wsProcedimientos(String userName, String password){
        this.userName = userName;
        this.password = password;
    }
    public void wsReferenciado1(){}

    public void wsReferenciado3(FileStream archivoAid){}

    public void wsReferenciado4(int NumeroDocumento){
        new servicio(this.userName,this.password);
    }
}
    
answered by 22.11.2018 / 22:06
source