P
Paul R
Hi.
I have a question about how to call a WebService from a a Windows Forms
application.
I have developed a WebService that has a Login method. Stripped down, it
looks like this….
public bool Login(string userName, string password )
{
bool bLoggedIn = false;
if( userName.Length > 0 && password.Length > 0 )
{
// bLoggedIn = do login here
if( bLoggedIn )
{
FormsAuthentication.SetAuthCookie( userName, false );
}
}
return bLoggedIn;
}
Each subsequent call will verify, who the user is, before continuing…..
string VerifyUserName(HttpApplication app)
{
string userName = app.Context.User.Identity.Name;
return userName;
}
While debugging the WebService, I tried to call the methods through Internet
Explorer (and FireFox). First I call the Login web method and then the
subsequent call. I have a breakpoint in the second call and can see that
the User.Identity.Name value is the same that I passed into the SetAuthCookie
call. So, I think I have coded the server correctly.
Now, when I try to call this from my Windows Forms application I get a
different result. The call to Login appears to behave identically. The
call to VerifyUserName fails because User.Identity is null. So, my guess
is I need to do something in my windows forms application to let each
subsequent call know who is making the call.
In my client code, I just create a new proxy to my webservice and call a
method. Is there some sort of Connection Context object that I need to
pass into each web service call? If so, how do you create it and how do you
pass it to a webservice.
Thanks in advance for your help.
I have a question about how to call a WebService from a a Windows Forms
application.
I have developed a WebService that has a Login method. Stripped down, it
looks like this….
public bool Login(string userName, string password )
{
bool bLoggedIn = false;
if( userName.Length > 0 && password.Length > 0 )
{
// bLoggedIn = do login here
if( bLoggedIn )
{
FormsAuthentication.SetAuthCookie( userName, false );
}
}
return bLoggedIn;
}
Each subsequent call will verify, who the user is, before continuing…..
string VerifyUserName(HttpApplication app)
{
string userName = app.Context.User.Identity.Name;
return userName;
}
While debugging the WebService, I tried to call the methods through Internet
Explorer (and FireFox). First I call the Login web method and then the
subsequent call. I have a breakpoint in the second call and can see that
the User.Identity.Name value is the same that I passed into the SetAuthCookie
call. So, I think I have coded the server correctly.
Now, when I try to call this from my Windows Forms application I get a
different result. The call to Login appears to behave identically. The
call to VerifyUserName fails because User.Identity is null. So, my guess
is I need to do something in my windows forms application to let each
subsequent call know who is making the call.
In my client code, I just create a new proxy to my webservice and call a
method. Is there some sort of Connection Context object that I need to
pass into each web service call? If so, how do you create it and how do you
pass it to a webservice.
Thanks in advance for your help.