Problem in calling a webservice asynchronously

G

Ginny

Hi,
I have a simple web service that returns a dataset. Its very simple. i call
the web service from a windows app. it works abosolutely fine when i can the
web service method synchronously. but when i try to call the method
asynchronosuly using the 'beginxxx' and 'endxxxx' it does not give any error
but at the same time, the datagrid on the form does not show any data as
well. the only code in my windows form is menitoned below. Kindly if some
one can assist.


private void button1_Click(object sender, System.EventArgs e)
{
Asynch.Service1 obj = new Asynch.Service1();
AsyncCallback cb = new AsyncCallback(callback);
obj.BeginGetDataAll(cb,obj);
}

private void callback(IAsyncResult ar)
{
Asynch.Service1 obj = (Asynch.Service1)ar.AsyncState;
DataSet ds = obj.EndGetDataAll(ar); // I have tried type casting also
here but still does not work --- DataSet ds =
(DataSet)obj.EndGetDataAll(ar);
dataGrid1.DataSource = ds.Tables[0];

}
 
J

John Saunders

Ginny said:
Hi,
I have a simple web service that returns a dataset. Its very simple. i
call
the web service from a windows app. it works abosolutely fine when i can
the
web service method synchronously. but when i try to call the method
asynchronosuly using the 'beginxxx' and 'endxxxx' it does not give any
error
but at the same time, the datagrid on the form does not show any data as
well. the only code in my windows form is menitoned below. Kindly if some
one can assist.


private void button1_Click(object sender, System.EventArgs e)
{
Asynch.Service1 obj = new Asynch.Service1();
AsyncCallback cb = new AsyncCallback(callback);
obj.BeginGetDataAll(cb,obj);
}

private void callback(IAsyncResult ar)
{
Asynch.Service1 obj = (Asynch.Service1)ar.AsyncState;
DataSet ds = obj.EndGetDataAll(ar); // I have tried type casting also

So, when you set a breakpoint here in the debugger, what do you see as
returned from the web service?

John
 
G

Ginny

Hi John,

It returns a dataset, but it doesnot have any rows so the gird simply shows
a + sign and when we expand, it shows nothing. the strange part is that the
synchronous version runs absolutely fine, meaning that the code in the
websiervice is fine. shall is send you the solution??

regards
ginny
 
J

John Saunders

Ginny said:
Hi John,

It returns a dataset, but it doesnot have any rows so the gird simply
shows
a + sign and when we expand, it shows nothing. the strange part is that
the
synchronous version runs absolutely fine, meaning that the code in the
websiervice is fine. shall is send you the solution??

Sorry, I won't have time to look at the solution.

However, you say it returns a DataSet. Have you looked through that returned
DataSet object to see exactly which tables are in it? I've seen things like
this when, for instance, the DataSet has "Table0" in it, when I was
expecting a specific table. This would give the appearance of no data, even
though the data are there - in a different table than the one you were
expecting.

John
 
G

Ginny

HI,

The dataset has the authors table. this is precisely the table name i gave
in the fill method. but does not contain any rows.

regards
Ginny
 
J

John Saunders

Ginny said:
HI,

The dataset has the authors table. this is precisely the table name i gave
in the fill method. but does not contain any rows.

Oh, well, it couldn't be easy, could it?

My next step would be to take a look at the XML being sent from the server
to the client. In particular, there must be at least _some_ data, or you
wouldn't have an authors table. The question is, what has caused the data to
be sufficient to produce an authors table, but insufficient to create any
authors rows?

In other situations, I've seen a difference in namespaces cause a web
service parameter to deserialize as null (Nothing in VB.NET). Maybe this is
something similar, but it would be necessary to see what's being sent and
received in order to know the real story.

If you don't already have a means of looking at your SOAP traffic, I
recommend that you take a look at http://www.pocketsoap.com.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top