I have a .net webservice (located in a different machine) that is called
twice from a windows form .net application.
The ws works fine if I called only one call, but failed if I called them
both, one after another. The following error occurs every time I called the
second web service:
System.Net.WebException was unhandled
Message="The underlying connection was closed: A connection that was
expected to be kept alive was closed by the server."
Source="System.Web.Services"
StackTrace:
at
System.Web.Services.Protocols.WebClientProtocol.Ge tWebResponse(WebRequest
request)
at
System.Web.Services.Protocols.HttpWebClientProtoco l.GetWebResponse(WebRequest
request)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at
WF_BCCR.cr.fi.bccr.indicadoreseconomicos.wsIndicad oresEconomicos.ObtenerIndicadoresEconomicosXML(Str ing
tcIndicador, String tcFechaInicio, String tcFechaFinal, String tcNombre,
String tnSubNiveles) in C:\Desarrollo\Visual Studio
2005\Projects\WF_BCCR\WF_BCCR\Web
References\cr.fi.bccr.indicadoreseconomicos\Refere nce.cs:line 121
at WF_BCCR.Form1.button1_Click(Object sender, EventArgs e) in
C:\Desarrollo\Visual Studio 2005\Projects\WF_BCCR\WF_BCCR\Form1.cs:line 45
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WF_BCCR.Program.Main() in C:\Desarrollo\Visual Studio
2005\Projects\WF_BCCR\WF_BCCR\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Code:
cr.fi.bccr.indicadoreseconomicos.wsIndicadoresEcon omicos wsCompra = new
wsIndicadoresEconomicos();
cr.fi.bccr.indicadoreseconomicos.wsIndicadoresEcon omicos wsVenta = new
wsIndicadoresEconomicos();
XmlDocument xmlVenta = new XmlDocument();
XmlDocument xmlCompra = new XmlDocument();
// Obtenga el dÃ*a de hoy
DateTime fecha = DateTime.Today;
int fechaAnno = fecha.Year;
int fechaMes = fecha.Month;
int fechaDia = fecha.Day;
String fechaString = fechaDia + "/" + fechaMes + "/" + fechaAnno;
String compra = wsCompra.ObtenerIndicadoresEconomicosXML("317",
fechaString, fechaString, "Grupo Nación GN S.A.", "N");
String venta = wsVenta.ObtenerIndicadoresEconomicosXML("318",
fechaString, fechaString, "GN Grupo Nación SA", "N");
// Cargue la información a estructuras XML
xmlCompra.LoadXml(compra);
xmlVenta.LoadXml(venta);
MessageBox.Show(xmlCompra.InnerXml.ToString());
MessageBox.Show(xmlVenta.InnerXml.ToString());
Webservice:
http://indicadoreseconomicos.bccr.fi...tnSubNiveles=N
Thank,
Lorenzo Jiménez