Question Question about in a web service

Joined
Jun 27, 2020
Messages
6
Programming Experience
3-5
Hi,

I'm trying to use a web service and I'm not getting it.
The web service is located at http://dev.efrete.com.br/Services/LogonService.asmx?wsdl .
The code implemented in summary form is:

C#:
            EfreteLogonService.LoginRequest loginrequestefrete = new EfreteLogonService.LoginRequest();
            EfreteLogonService.LoginResponse loginresponseefrete = new EfreteLogonService.LoginResponse();
            loginrequestefrete.Senha = "tempsenha";
            loginrequestefrete.Usuario = "tempusuario";
            loginrequestefrete.Integrador = "tempintegrador";
            loginrequestefrete.Versao = 1;
MessageBox.Show(loginresponseefrete.Sucesso.ToString().Trim());
I'm just having a false result in the messagebox. The correct thing is to have a true result.
Can someone insert this web service and identify what I am implementing wrong or is missing.

Thankyou.
 
Last edited by a moderator:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
1,406
Location
Virginia Beach, VA
Programming Experience
10+
You need to actually call Login().
 
Joined
Jun 27, 2020
Messages
6
Programming Experience
3-5
Good Morning,
Thanks for the answer.
It is that login and logout are interfaces that are within the web service. I tried unsuccessfully to use these interfaces and I couldn't.
How to use an interface that is in the web service?
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
1,406
Location
Virginia Beach, VA
Programming Experience
10+
Show us your code where you attempted this.
 
Joined
Jun 27, 2020
Messages
6
Programming Experience
3-5
I did not find an example using this procedure. I was unable to use the interface that is in the web service.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
1,406
Location
Virginia Beach, VA
Programming Experience
10+
Joined
Jun 27, 2020
Messages
6
Programming Experience
3-5
I tried:

EfreteLogonService.LogonServiceSoap logonservicesoap = new EfreteLogonService.LogonServiceSoap();

But I get a message that "cannot create an instance of the interface".

I also tried to do:

test = EfreteLogonService.LogonServiceSoap.Login();

But I get a message that "no overload for method 'login' takes 0 arguments".

I made other attempts, but I couldn't get access to call the login.
 

Sheepings

Senior Programmer
Staff member
Joined
Sep 5, 2018
Messages
1,259
Location
UK
Programming Experience
10+
Well that error seems self explanatory. You can not create an instance of an interface. Interfaces are contracts between objects. The same rule applies to using abstract classes, but you can however instantiate a class that implements that interface.

Once again, if you don't show your code. Have fun in the debugger, because there is nothing more we can do to help you. So are you willing and able to show your code or not?
 
Joined
Jun 27, 2020
Messages
6
Programming Experience
3-5
No problem.
Below is the complete code snippet with all attempts.
In the last messagebox not marked as a comment I get the false answer. In subsequent messageboxs I get null, when I should receive a value.
There have been other attempts that have already been deleted.

C#:
            EfreteLogonService.LoginRequest1 loginrequestefrete1 = novo EfreteLogonService.LoginRequest1 ();

            EfreteLogonService.LoginResponse1 loginresponseefrete1 = novo EfreteLogonService.LoginResponse1 ();







            //EfreteLogonService.LogonServiceSoap logon = new EfreteLogonService.LoginRequest ();

            // teste = EfreteLogonService.LogonServiceSoap.Login ();







            EfreteLogonService.LoginRequest loginrequestefrete = new EfreteLogonService.LoginRequest ();

            EfreteLogonService.LoginResponse loginresponseefrete = new EfreteLogonService.LoginResponse ();

            //EfreteLogonService.Request request = new EfreteLogonService.Request ();

            //EfreteLogonService.LogonServiceSoap logonservicesoap = new EfreteLogonService.LogonServiceSoap ();

            //EfreteLogonService.LogonServiceSoapChannel logonservicesoap = new EfreteLogonService.LogonServiceSoapClient ();



            loginrequestefrete.Senha = "tempsenha";

            loginrequestefrete.Usuario = "tempusuario";

            loginrequestefrete.Integrador = "tempintegrador";

            loginrequestefrete.Versao = 1;

            // loginrequestefrete.



            //MessageBox.Show(loginrequestefrete1.LoginRequest.);

        



            //loginrequestefrete1.LoginRequest.Senha = "tempsenha";

            //loginrequestefrete1.LoginRequest.Usuario = "tempusuario";

            //loginrequestefrete1.LoginRequest.Integrador = "tempintegrador";

            //loginrequestefrete1.LoginRequest.Versao = 1;



            //MessageBox.Show(loginrequestefrete.);

            // loginrequestefrete;



            //MessageBox.Show (loginrequestefrete.ToString ());



            //EfreteLogonService.Request ();

        



            MessageBox.Show (loginresponseefrete.Sucesso.ToString (). Trim ());

            //MessageBox.Show(loginresponseefrete1.LoginResult.Sucesso.ToString (). Trim ());

            //MessageBox.Show(loginresponseefrete.Excecao.Mensagem.ToString (). Trim ());

            //MessageBox.Show(loginresponseefrete.Excecao.Codigo.ToString (). Trim ());

            //MessageBox.Show(loginresponseefrete.Token.ToString (). Trim ());
 
Last edited:

Sheepings

Senior Programmer
Staff member
Joined
Sep 5, 2018
Messages
1,259
Location
UK
Programming Experience
10+
Code tags please. Edit your post and put your code in code tags.
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
742
Location
Norway
Programming Experience
10+
It is easy to figure this out, all you have to do is start writing EfreteLogonService. (dot) and intellisense shows the members. In the member list there are a few request and response classes and a LogonServiceSoapClient class, which is what you create an instance of to interact with the service.
//EfreteLogonService.LogonServiceSoapChannel logonservicesoap = new EfreteLogonService.LogonServiceSoapClient();
A class is a type so that is also the type of variable, unless you are converting/casting it so something else, but then you should know. Just use the var dynamic variable declaration for type inference:
C#:
var client = new EfreteLogonService.LogonServiceSoapClient();
Now you can use the client instance to call its methods, for example the Login method. Intellisense will show you what type of arguments it expects.
 
Joined
Jun 27, 2020
Messages
6
Programming Experience
3-5
Using what I had already programmed and the code below based on your information I got a response token from the web service.
Waiting for a response from the company responsible for the web service to validate the received token.
Thank you very much for now.

C#:
EfreteLogonService.LogonServiceSoapClient logonservicesoapcliente = new EfreteLogonService.LogonServiceSoapClient();

logonservicesoapcliente.Login(loginrequestefrete);
MessageBox.Show(logonservicesoapcliente.Login(loginrequestefrete).Sucesso.ToString());
MessageBox.Show(logonservicesoapcliente.Login(loginrequestefrete).Token.ToString());
 
Top Bottom