Alex
Alex

Reputation: 6149

Calling a web service from a .net windows application

I need to call a web service from a .net web application, here is my code:

LoginRequest req = new LoginRequest();
LoginRequestBody reqBody = new LoginRequestBody();

reqBody.username = txtUsername.Text;
reqBody.password = txtPassword.Text;

req.Body = reqBody;

LoginResponse resp = new LoginResponse();
LoginResponseBody respBody = new LoginResponseBody();

resp.Body = respBody;
MessageBox.Show(respBody.LoginResult.ToString());

The message returned is always false, while the message from the web service (when I test directly) is returning true, what's wrong with my code?

Upvotes: 0

Views: 109

Answers (1)

RB.
RB.

Reputation: 37172

You are not actually calling the web-service! You should not be creating a response directly - you should be asking the web-service for one, e.g.

LoginResponse response = LoginService.Login(req);

However, I don't know what your service is actually called, so the above is just a sample.

Upvotes: 6

Related Questions