J
jez
I've been trying for the past two days to get an asynchronous web service to
work. After understanding (thanks to an online tutorial and the Microsoft Web
Services book) all the concepts (call back, async result etc...), I still
haven't managed to get it to work. I am able however to use a synchronous web
service.
Here's the code that I have on the client. The webservice takes a string and
returns a string.
static void Main(string[] args) {
jezWS.stoproService ws = new jezWS.stoproService();
AsyncCallback cb = new AsyncCallback (Class1.ReportCallBack);
IAsyncResult ar = ws.BegingetPhone("name", cb, ws);
}
public static void ReportCallBack (IAsyncResult ar) {
Console.WriteLine("*** Got response from Web Service ***");
stoproService ws = (stoproService) ar.AsyncState;
Console.WriteLine(ws.EndgetPhone(ar));
}
The code compiles okay, but after the third line in the Main method it
simply exits. If however, I put the third line of the ReportCallBack method
in the main method (i.e. the one with EndgetPhone), I do get a response from
the web service but it's just not asynchronous! I just want to be able to
show for instance text on the Console while waiting for a response.
Thanks so much for the help,
jez
work. After understanding (thanks to an online tutorial and the Microsoft Web
Services book) all the concepts (call back, async result etc...), I still
haven't managed to get it to work. I am able however to use a synchronous web
service.
Here's the code that I have on the client. The webservice takes a string and
returns a string.
static void Main(string[] args) {
jezWS.stoproService ws = new jezWS.stoproService();
AsyncCallback cb = new AsyncCallback (Class1.ReportCallBack);
IAsyncResult ar = ws.BegingetPhone("name", cb, ws);
}
public static void ReportCallBack (IAsyncResult ar) {
Console.WriteLine("*** Got response from Web Service ***");
stoproService ws = (stoproService) ar.AsyncState;
Console.WriteLine(ws.EndgetPhone(ar));
}
The code compiles okay, but after the third line in the Main method it
simply exits. If however, I put the third line of the ReportCallBack method
in the main method (i.e. the one with EndgetPhone), I do get a response from
the web service but it's just not asynchronous! I just want to be able to
show for instance text on the Console while waiting for a response.
Thanks so much for the help,
jez