Saturday, March 24, 2012

Web service or vbscript?

The project I work on is a forum. Here is a scenario: if someone replies to a topic people who are listening to the topic should be notified via email. The email should be personally addressed. (Hello <user name>, new reply for topic. Click here to go to forum reply...). Anyway I have to query the database, get the list of people subscribed for the topic and send the individual emails out. Another requirement is that this should be independent of my web page processing. I would not want my processing to block for the task to complete.

Should I rely on a web service or just plain vbscript to do this?

If I am using a web service how do I call it during web page processing? (And it should be asynchronous too...!)

Regarding VbScript VS WebService, use a web service.

Regarding if it should be async, it should.

Regarding how to call it, see this article...

Asynchronous Web Services

http://www.informit.com/articles/article.aspx?p=29395&seqNum=1

...or any of the other many fine articles on the web.

HTH.

Thank you.

-- Mark Kamoski


Hi,

As far as I know, WebService is better. To implement Asynchronous Web Services, there is a sample as below.

WebService (name: WH)

using System;using System.Web;using System.Web.Services;using System.Web.Services.Protocols;[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]public class Service : System.Web.Services.WebService{public Service () {//Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod]public voidSendMail() {//put your codes about sending mail into here. }}
 In your aspx page, you can call the WH WebService with Asynchronous approach.
 
protected void WSSendingMail() { WH.Service someWS =new WH.Service(); System.AsyncCallback cb =new AsyncCallback(showmsg); someWS.BeginSendMail(cb, someWS); }void showmsg(IAsyncResult ar) { WH.Service someWS = (WH.Service)ar.AsyncState; someWS.EndSendMail(ar); }
Hope this can help.
 

0 comments:

Post a Comment