By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,583 Members | 617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,583 IT Pros & Developers. It's quick & easy.

Efficient Asynchronous Call to Webservice

P: n/a
Hi,

I have to make multiple calls (about 400K) to a webservice which returns a
string. And currently it takes about a week to make all the calls. Instead of
waiting for the webservice result before i make the next call, I rather want
to make the calls and let the results comeback at its own pace. I used
Asynchronous calling and callback method, but it does not seems to work. I am
sure, asynchronous way will improve my program execution exponentially. I
would appreciate if someone can help me with this. And by the way, i did not
see an Begin and End methods.
Here is my method which is making the webservice calls.

public static Boolean WebServiceCallsXY(string x, string y)
{
try
{
UsernameToken token = new UsernameToken("AAA", "BBB",
PasswordOption.SendPlainText);
MbrSrvWse wseProxy = new MbrSrvWse ();
wseProxy.SetClientCredential<UsernameToken>(token) ;
wseProxy.SetPolicy("ProvideUsernameToken");

IndividualDetailRequest test = new IndividualDetailRequest();
test.UserId = x;
test.Pin = y;
IndividualDetailResponse response =
wseProxy.IndividualDetail(test);

if (response.Result.Length 0)
{
if (response.Result.ToString().ToLower().Equals("a"))
{
return true;
}
if (response.Result.ToString().ToLower().Equals("b"))
{
return false;
}
}
return false;
}
catch (Exception e)
{
Console.WriteLine("The following error '{0}' -------- {1} :
{2} ", e.Message, e.StackTrace, x);
return false;
}
}

--
Kalyan
Nov 8 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
=?Utf-8?B?S2FseWFu?= <Ka****@discussions.microsoft.comwrote in
news:AA**********************************@microsof t.com:
I have to make multiple calls (about 400K) to a webservice which
returns a string. And currently it takes about a week to make all the
calls. Instead of waiting for the webservice result before i make the
next call, I rather want to make the calls and let the results
comeback at its own pace. I used Asynchronous calling and callback
method, but it does not seems to work. I am sure, asynchronous way
will improve my program execution exponentially. I would appreciate if
someone can help me with this. And by the way, i did not see an Begin
and End methods.
Surely you must have a better way ... ???

Do you have access to the developer who built the original web service?
Perhaps you can make a bulk call.

As for asynchronous web services, .NET 2.0 uses events rather than
Begin/End functions.
Nov 8 '07 #2

P: n/a
I don't think VS2005 creates the Begin/End methods for you like VS2003 did.
instead it creates <methodname>Async & <methodname>Completed events.

See http://objectsharp.com/cs/blogs/bruc...0/02/3480.aspx

You can read more on this in the "Asynchronous Tasks" at
http://msdn.microsoft.com/msdnmag/is...10/WickedCode/

Good example...
http://msdn2.microsoft.com/en-us/lib...sk(VS.80).aspx

"Kalyan" wrote:
Hi,

I have to make multiple calls (about 400K) to a webservice which returns a
string. And currently it takes about a week to make all the calls. Instead of
waiting for the webservice result before i make the next call, I rather want
to make the calls and let the results comeback at its own pace. I used
Asynchronous calling and callback method, but it does not seems to work. I am
sure, asynchronous way will improve my program execution exponentially. I
would appreciate if someone can help me with this. And by the way, i did not
see an Begin and End methods.
Here is my method which is making the webservice calls.

public static Boolean WebServiceCallsXY(string x, string y)
{
try
{
UsernameToken token = new UsernameToken("AAA", "BBB",
PasswordOption.SendPlainText);
MbrSrvWse wseProxy = new MbrSrvWse ();
wseProxy.SetClientCredential<UsernameToken>(token) ;
wseProxy.SetPolicy("ProvideUsernameToken");

IndividualDetailRequest test = new IndividualDetailRequest();
test.UserId = x;
test.Pin = y;
IndividualDetailResponse response =
wseProxy.IndividualDetail(test);

if (response.Result.Length 0)
{
if (response.Result.ToString().ToLower().Equals("a"))
{
return true;
}
if (response.Result.ToString().ToLower().Equals("b"))
{
return false;
}
}
return false;
}
catch (Exception e)
{
Console.WriteLine("The following error '{0}' -------- {1} :
{2} ", e.Message, e.StackTrace, x);
return false;
}
}

--
Kalyan
Nov 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.