I have created one web-service and I call that web-service from my another web-application. My problem is that when I am calling that web-service Its working fine But for the long running process It gives me exception for time-out.
My webservice method:-
[WebMethod]
public
DataSet SearchInvoice(string sStDate,
string sEndDate,
string sPayment,
string scmbOrderType)
string sQuery = "";
DataTable dt = new DataTable();
if (sPayment != "Select Any")
{
if (sPayment != "Select Any")
{
sQuery = " SELECT CONVERT(BIT, 0) AS [Select], Invoice_M.Invoice_No AS InvoiceNo, CONVERT(VARCHAR, Invoice_M.Invoice_Date, 103) AS [Invoice_date] , " +
" CONVERT(varchar, Invoice_M.Invoice_Time, 108) AS [Invoice_Time], InvoicePay_MD.PayMode AS PaymentMode, Invoice_M.BillAmount AS Amount " +
" FROM Invoice_M INNER JOIN " +
" InvoicePay_MD ON Invoice_M.Invoice_No = InvoicePay_MD.Invoice_No WHERE Invoice_M.DelFlag <> 1 and ";
}
if (sPayment != "ALL")
{
sQuery += " InvoicePay_MD.PayMode ='" + sPayment + "' and ";
}
if (scmbOrderType != "ALL" && scmbOrderType != "Select Any")
{
sQuery += " Invoice_M.ModuleName ='" + scmbOrderType + "' and ";
}
sQuery += " convert(datetime, Invoice_M.Invoice_Date,103) between CONVERT(datetime, '" + sStDate + "', 103) and dateadd(day,1, CONVERT(datetime, '" + sEndDate + "',103)) and ";
sQuery += "1=1 order by newid()";
objdb.FillDataTable(sQuery, dt);
public object Call_WebService(string webServiceAsmxUrl, string serviceName, string methodName, object[] args)
{
System.Net.WebClient client = new System.Net.WebClient();
//-Connect To the web service
System.IO.Stream stream = client.OpenRead(webServiceAsmxUrl + "?wsdl");
//Read the WSDL file describing a service.
ServiceDescription description = ServiceDescription.Read(stream);
//LOAD THE DOM'''''''''''''''''''''''''''
//--Initialize a service description importer.
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap12";
// Use SOAP 1.2.
importer.AddServiceDescription(description, null, null);
//--Generate a proxy client.
importer.Style = ServiceDescriptionImportStyle.Client;
//--Generate properties to represent primitive values.
importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;
//Initialize a Code-DOM tree into which we will import the service.
CodeNamespace nmspace = new CodeNamespace();
CodeCompileUnit unit1 = new CodeCompileUnit();
unit1.Namespaces.Add(nmspace);
//Import the service into the Code-DOM tree.
//This creates proxy code that uses the service.
ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);
if (warning == 0)
{
//--Generate the proxy code
CodeDomProvider provider1 = CodeDomProvider.CreateProvider("VB");
//--Compile the assembly proxy with the // appropriate references
string[] assemblyReferences = null;
assemblyReferences = new string[] {
"System.dll",
"System.Web.Services.dll",
"System.Web.dll",
"System.Xml.dll",
"System.Data.dll"
};
CompilerParameters parms = new CompilerParameters(assemblyReferences);
parms.GenerateInMemory = true;
//(Thanks for this line nikolas)
CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);
//-Check For Errors
if (results.Errors.Count > 0)
{
CompilerError oops = default(CompilerError);
//foreach ( oops in results.Errors) {
// System.Diagnostics.Debug.WriteLine("========Compiler error============");
// System.Diagnostics.Debug.WriteLine(oops.ErrorText);
//}
//throw new System.Exception("Compile Error Occurred calling webservice.");
}
//--Finally, Invoke the web service method
object wsvcClass = results.CompiledAssembly.CreateInstance(serviceName);
MethodInfo mi = wsvcClass.GetType().GetMethod(methodName);
return mi.Invoke(wsvcClass, args);
}
else
{
return null;
}
}
I have set the all required configuration :-
1) session TimeOut
2) http runtime execution time out
3) Script Timeout
4) Connection Time Out
I want to know whether I have to set the time-out for web-service and How?
trivedimca
Member
80 Points
148 Posts
Web Service Time Out
Jul 14, 2010 07:19 AM|LINK
Hi,
I have created one web-service and I call that web-service from my another web-application. My problem is that when I am calling that web-service Its working fine But for the long running process It gives me exception for time-out.
My webservice method:-
[WebMethod]
public DataSet SearchInvoice(string sStDate, string sEndDate, string sPayment, string scmbOrderType)
string sQuery = ""; DataTable dt = new DataTable(); if (sPayment != "Select Any") { if (sPayment != "Select Any") { sQuery = " SELECT CONVERT(BIT, 0) AS [Select], Invoice_M.Invoice_No AS InvoiceNo, CONVERT(VARCHAR, Invoice_M.Invoice_Date, 103) AS [Invoice_date] , " + " CONVERT(varchar, Invoice_M.Invoice_Time, 108) AS [Invoice_Time], InvoicePay_MD.PayMode AS PaymentMode, Invoice_M.BillAmount AS Amount " + " FROM Invoice_M INNER JOIN " + " InvoicePay_MD ON Invoice_M.Invoice_No = InvoicePay_MD.Invoice_No WHERE Invoice_M.DelFlag <> 1 and "; } if (sPayment != "ALL") { sQuery += " InvoicePay_MD.PayMode ='" + sPayment + "' and "; } if (scmbOrderType != "ALL" && scmbOrderType != "Select Any") { sQuery += " Invoice_M.ModuleName ='" + scmbOrderType + "' and "; } sQuery += " convert(datetime, Invoice_M.Invoice_Date,103) between CONVERT(datetime, '" + sStDate + "', 103) and dateadd(day,1, CONVERT(datetime, '" + sEndDate + "',103)) and "; sQuery += "1=1 order by newid()"; objdb.FillDataTable(sQuery, dt);public object Call_WebService(string webServiceAsmxUrl, string serviceName, string methodName, object[] args) { System.Net.WebClient client = new System.Net.WebClient(); //-Connect To the web service System.IO.Stream stream = client.OpenRead(webServiceAsmxUrl + "?wsdl"); //Read the WSDL file describing a service. ServiceDescription description = ServiceDescription.Read(stream); //LOAD THE DOM''''''''''''''''''''''''''' //--Initialize a service description importer. ServiceDescriptionImporter importer = new ServiceDescriptionImporter(); importer.ProtocolName = "Soap12"; // Use SOAP 1.2. importer.AddServiceDescription(description, null, null); //--Generate a proxy client. importer.Style = ServiceDescriptionImportStyle.Client; //--Generate properties to represent primitive values. importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties; //Initialize a Code-DOM tree into which we will import the service. CodeNamespace nmspace = new CodeNamespace(); CodeCompileUnit unit1 = new CodeCompileUnit(); unit1.Namespaces.Add(nmspace); //Import the service into the Code-DOM tree. //This creates proxy code that uses the service. ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1); if (warning == 0) { //--Generate the proxy code CodeDomProvider provider1 = CodeDomProvider.CreateProvider("VB"); //--Compile the assembly proxy with the // appropriate references string[] assemblyReferences = null; assemblyReferences = new string[] { "System.dll", "System.Web.Services.dll", "System.Web.dll", "System.Xml.dll", "System.Data.dll" }; CompilerParameters parms = new CompilerParameters(assemblyReferences); parms.GenerateInMemory = true; //(Thanks for this line nikolas) CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1); //-Check For Errors if (results.Errors.Count > 0) { CompilerError oops = default(CompilerError); //foreach ( oops in results.Errors) { // System.Diagnostics.Debug.WriteLine("========Compiler error============"); // System.Diagnostics.Debug.WriteLine(oops.ErrorText); //} //throw new System.Exception("Compile Error Occurred calling webservice."); } //--Finally, Invoke the web service method object wsvcClass = results.CompiledAssembly.CreateInstance(serviceName); MethodInfo mi = wsvcClass.GetType().GetMethod(methodName); return mi.Invoke(wsvcClass, args); } else { return null; } }I have set the all required configuration :-
1) session TimeOut
2) http runtime execution time out
3) Script Timeout
4) Connection Time Out
I want to know whether I have to set the time-out for web-service and How?
Thanks and REgards
Prashant Trivedi.
sandeep tada
Member
208 Points
50 Posts
Re: Web Service Time Out
Jul 14, 2010 11:45 AM|LINK
Hi
set web service 's
command timeout to 0
Sandeep
Please mark as answer if my post helps you....
Follow me on Blog for tech help
trivedimca
Member
80 Points
148 Posts
Re: Web Service Time Out
Jul 15, 2010 06:13 AM|LINK
Thanks ,
My problem is solved by adding the following line while calling the web-service:-
((System.Web.Services.Protocols.WebClientProtocol)(wsvcClass)).Timeout = 1000000;
Thanks
Prashant Trivedi
surjyendubag
Member
2 Points
1 Post
Re: Web Service Time Out
Dec 24, 2010 12:11 PM|LINK
Thanks................
((System.Web.Services.Protocols.WebClientProtocol)(wsvcClass)).Timeout = 1000000;
Above line is very helpfull for dynamic webservice calling when it the process is very lengthy.
neez
Member
67 Points
44 Posts
Re: Web Service Time Out
Dec 27, 2010 05:17 AM|LINK
increae the TimeOut in the web.config file where you have specify the bindings and your serivce end point address. hope it will work fine for you.