那位朋友对WEB SERVICE ,BeginInvoke异步调用比较熟,遇到奇怪问题WEBservice 正常,可以在IE手工调试下正常使用,但程序 BeginInvoke异步调用时,运行到BeginLogOn就直接跳走了,没有运行其下面的return ..运行代码如下:
/// <res/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(" http://localhost:19496/LogOn", RequestNamespace=" http://localhost:19496/", ResponseNamespace=" http://localhost:19496/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int LogOn(string userid, string password, bool WriteDog) {
object[] results = this.Invoke("LogOn", new object[] {
userid,
password,
WriteDog});
return ((int)(results[0]));
}
/// <res/>
public System.IAsyncResult BeginLogOn(string userid, string password, bool WriteDog, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("LogOn", new object[] {
userid,
password,
WriteDog}, callback, asyncState);
pkman(124086091) 22:08:01
局部变量:
/// <res/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(" http://localhost:19496/LogOn", RequestNamespace=" http://localhost:19496/", ResponseNamespace=" http://localhost:19496/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public int LogOn(string userid, string password, bool WriteDog) {
object[] results = this.Invoke("LogOn", new object[] {
userid,
password,
WriteDog});
return ((int)(results[0]));
}
/// <res/>
public System.IAsyncResult BeginLogOn(string userid, string password, bool WriteDog, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("LogOn", new object[] {
userid,
password,
WriteDog}, callback, asyncState);
pkman(124086091) 22:08:01
局部变量:
抓取分析看看
http://hi.csdn.net/attachment/201102/16/774212_1297887126HXR1.jpg
http://hi.csdn.net/attachment/201102/16/774212_1297887174YS3Z.jpg
上面的代码是WEB服务里的代码,下面是调用服务的客户端程序,每次大约label4.Text =2000左右时,ar.IsCompleted =TRUE;此时,rs.EndLogOn(ar), AR都仍然没有值。所以,调用失败。
int p = 1;
while (ar.IsCompleted ==false)
{
p++;
label4.Text = p.ToString();
label4.Refresh();
}
int rtn = rs.EndLogOn(ar);
if (rtn==0)
{
MessageBox.Show("登录失败!请检查用户名和密码输入是否正确。","提示", MessageBoxButtons.OK ,MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
label37.Text ="";
label37.Refresh();
}
else if (rtn==1){}
else
{
MessageBox.Show("服务器验证失败!请检查服务器配置是否正确。("+rtn.ToString()+")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
label37.Text ="";
label37.Refresh();
}