我想在另一个webservice调用中使用webservice调用的结果,就在它之后......但是第二个webservice在第一个webservice的结果之前被调用.......我正在使用wp7 app .....
PhoneService.WebServiceSoapClient register = new PhoneService.WebServiceSoapClient();
register.InsertNewCollegeCompleted += register_InsertNewCollegeCompleted;
register.InsertNewCollegeAsync(newCollegeName);
register.InsertNewCollegeCompleted += register_InsertNewCollegeCompleted;
register.insertdataCompleted += register_insertdataCompleted;
register.insertdataAsync(Name.Text, email.Text, contact.Text,
int.Parse(partnerid.Text.Substring(2)), student_no.Text, pass.Text,
gender, branchid, yearid, collegeid, shirtreqd, accom);
register.insertdataCompleted += register_insertdataCompleted;
void register_insertdataCompleted(object sender, PhoneService.insertdataCompletedEventArgs e)
{
MessageBox.Show("TT ID is" + e.Result);
}
void register_InsertNewCollegeCompleted(object sender, PhoneService.InsertNewCollegeCompletedEventArgs e)
{
collegeid = e.Result;
}
答案 0 :(得分:0)
您可以使用Asynccalls,您基本上想先使用注册,然后在您的登录Api中使用它的响应。
我通过使异步调用等待来完成此操作,您可以查看链接。 http://developer.nokia.com/community/wiki/Asynchronous_Programming_For_Windows_Phone_8
而且这也会有所帮助:
http://www.codeproject.com/Articles/518856/Task-Parallel-Library-and-async-await-Functionalit
答案 1 :(得分:0)
在第一次服务呼叫的已完成方法中执行第二次Web服务调用
在您的情况下,调用register_InsertNewCollegeCompleted中的register.insertdataAsync方法
{
....
....
PhoneService.WebServiceSoapClient register =
new PhoneService.WebServiceSoapClient();
register.InsertNewCollegeCompleted += register_InsertNewCollegeCompleted;
register.InsertNewCollegeAsync(newCollegeName);
....
....
}
void register_InsertNewCollegeCompleted(object sender, PhoneService.InsertNewCollegeCompletedEventArgs e)
{
collegeid = e.Result;
register.insertdataCompleted += register_insertdataCompleted;
register.insertdataAsync(Name.Text, email.Text, contact.Text,
int.Parse(partnerid.Text.Substring(2)), student_no.Text, pass.Text,
gender, branchid, yearid, collegeid, shirtreqd, accom);
}
void register_insertdataCompleted(object sender, PhoneService.insertdataCompletedEventArgs e)
{
MessageBox.Show("TT ID is" + e.Result);
}