RTSol
asked on
Call web service Asynchronously
Hi,
I have a web page in which there is a User Control. In this there is a call to a web service that will start a work that can last up to 5 minutes. Now, the web service returns nothing and takes no parameters. It works against the database and creates a number of PDF documents and stores them in the database. My call to the web service looks like this:
Service1Client client = new Service1Client();
client.makeInvoices();
client.Close();
My problem, as you can understand, is that my web page is waiting for a result from the web service and thus freezes and eventually crashes from the timeout. All I want to do is to start the web service and then forget about it and serve the page to the client. It works as expected in that the web service finishes its job even if the page crashes. My web service (WCF) looks like this:
Service1.svc:
using System;
using System.Collections.Generic ;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.Serializati on;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Text.RegularExpress ions;
using System.Web;
using Aspose.Words;
namespace invoiceService
{
public class Service1 : IService1
{
public void makeInvoices()
{
// very time consuming job
}
}
}
IService1.cs:
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Runtime.Serializati on;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace invoiceService
{
[ServiceContract]
public interface IService1
{
[OperationContract]
void makeInvoices();
}
}
How can I get the desired functionality?
Best regards
RTSol
I have a web page in which there is a User Control. In this there is a call to a web service that will start a work that can last up to 5 minutes. Now, the web service returns nothing and takes no parameters. It works against the database and creates a number of PDF documents and stores them in the database. My call to the web service looks like this:
Service1Client client = new Service1Client();
client.makeInvoices();
client.Close();
My problem, as you can understand, is that my web page is waiting for a result from the web service and thus freezes and eventually crashes from the timeout. All I want to do is to start the web service and then forget about it and serve the page to the client. It works as expected in that the web service finishes its job even if the page crashes. My web service (WCF) looks like this:
Service1.svc:
using System;
using System.Collections.Generic
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.Serializati
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Text.RegularExpress
using System.Web;
using Aspose.Words;
namespace invoiceService
{
public class Service1 : IService1
{
public void makeInvoices()
{
// very time consuming job
}
}
}
IService1.cs:
using System;
using System.Collections.Generic
using System.Linq;
using System.Runtime.Serializati
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace invoiceService
{
[ServiceContract]
public interface IService1
{
[OperationContract]
void makeInvoices();
}
}
How can I get the desired functionality?
Best regards
RTSol
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Have it working now.
Best regards
RTSol