Very fast and light web call, which technology to use: legacy web service or HttpWebRequest
I need some insecure, fast, light and easy to implement web method. Something like this:
// Client side
// Parametrize client address which is dynamic and we don't know until run-time
myClient.Address = "http://example.com/method.aspx/?input=" + value;
string result = "";
if (myClient.TryCallWebMethod(out result))
// Web method succeed. Use returned value.
else
// Web method failed. No problem, go with plan B.
// Server side
Response.Write("Answer is: " + Request.QueryString[input]);
I know this is reconstructing the wheel, but what I need is as simple as above code. I can implement client with HttpWebRequest
but maybe using a legacy Web Service
is a better choice.
I have tried WCF
but there are more choices which I don't need like sessions, security, etc. Also I did a localhost benchmarking and WCF
came to it's knees at 200 concurrent requests, where I need a support of more than 1000 concurrent calls which is a normal load for an aspx
page.
This web method is gonna be consumed from a a开发者_StackOverflowsp.net page. I never used a legacy web service, is it OK for my scenario or like WCF
it has a dozen of configurations and certificate installations... ?
After going through the operations provided by WebClient
, it looks like it just wraps a HttpWebRequest
functionality and provides extra utility operations. Hence I would suggest you to go for HttpWebRequest
.
Also on the server side, try to go for a HttpHandler
instead of aspx page (handlers are light weight)
If this is a standard ASPX page you could use a WebClient:
using (var client = new WebClient())
{
var url = "http://example.com/method.aspx?input=" + HttpUtility.UrlEncode(value);
string result = client.DownloadString(url);
}
精彩评论