Saturday, March 24, 2012
System.Net.WebException: The underlying connection was closed:
We have deployed a webservice (asmx.cs) to a server. We have created a windo
ws app (C# using visual studios.net 2003 Enterprise Arch) that refers to the
web service. In the windows app, we added the web reference - referring to
the ?wsdl file. The C# co
de is quite simple:
VOSEWebServicesDevW.WebServices WebSvcW = new VOSEWebServicesDevW.WebService
s();
returncode = WebSvcW.OMTestAddOrderXML(comboBox3.Text,int.Parse(textBox2.Tex
t),comboBox4.Text);
This works fine the first time- but when it sits a few minutes and we retry
, we receive...
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Net.WebException: The underlying connection was closed: An unexpected
error occurred on a send.
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest
request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebReq
uest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String method
Name, Object[] parameters)
at TestWebServiceW.VOSEWebServicesDevW.WebServices.OMTestAddOrderXML(String
strCompany, Int32 intOrderNo, String strOrderType)
at TestWebServiceW.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, I
nt32 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.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr
wparam, IntPtr lparam)
The project for the web service has a web.config file. I see no settings in
there of interest. I am new to this.
I would appreciate the guidance on what to do in the windows app C# code to
correctly access the web service on the team's server without having to clos
e & restart the windows app.
Thanks,
Tim Reynolds
VerizonHi Tim,
From your description, you've a ASP.NET webservcie and created a Winform
client app to consume it. However, when calling the webservice, you found
it worked well the first time but occured unexpected error the second time
after a few minutes, yes?
From the code you provided(calling the webservice), it seems all right and
I don't think the problem is likely in the client application. I'm not sure
about the webservice's detailed code logic in its webmethods but from the
method's signature:
WebSvcW.OMTestAddOrderXML(comboBox3.Text,int.Parse(textBox2.Text),comboBox4.
Text);
it takes simply type params, so I think we can test the webservice through
IE, open the certain url (http://...... .asmx) in the IE and call the
webservice thourgh it. It is better if you can use VS.NET to debug the
webservice on the serverside to see whether the problem also occured when
calling it from IE. If still remains, we can confirm that the problem is
not caused by the winform client , do you think so?
In addition, as for creating client application to consume webservice,
below is the related web link in MSDN:
#Creating Clients for XML Web Services
http://msdn.microsoft.com/library/e...atingclientsfor
webservices.asp?frame=true
Hope also helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Tim,
Have you had a chance to view the suggestions in my last reply or have you
got any progresses on this issue? If there is anything else I can help,
please feel free to post here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Thanks for your reply. However, when I try to go directly to the ..asmx url
via IA, when I click on the name of the web service in order to test, I rec
eive this message - Test
The test form is only available for requests from the local machine. There
fore, I am unclear on how to proceed. The server is in another state so I ca
n't logon directly to it in order to test from my location. How shall I pro
ceed?
Thank you,
Tim Reynolds
Verizon
Hi Tim,
Any progress on this issue? If you have any problems on this or if there're
anything else I can help, please feel free to let me know. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Tim,
From your reply, you haven't the certain permission to logon the server
which host the webservice, yes? Then, I think we can do the following tests
on the webservice:
1. Creating a client proxy through the following guide(using wsdl.exe
rather than via VS.NET) and consume the webservice by the geneated proxy to
see whether the webservice still fail.
#Creating an XML Web Service Proxy
http://msdn.microsoft.com/library/e...atingWebService
Proxy.asp?frame=true
2. I'm not sure whether you have ever tried calling a webservice via
javascript(DHTML) in a webpage, if not, you may have a look at the
following reference:
#Accessing Web Services From DHTML
http://msdn.microsoft.com/library/e...001.asp?frame=t
rue
If you're able to perform a test via the DHTML way, we can further confirm
whether the problem is with the serverside or not.
In addtion, you can create a simple webservice( similiar with the one
you're consuming, maybe just take 2 string parameters) on your local
machine or a remote machine which you have full control on it. And then
call it on the local machine to see whether the same problem occurs. If
not, that also probably proof that the problem is likely due to the
webservice's serverside processing.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Thursday, March 22, 2012
System.Reflection
application as opposed to a Windows application?
For example, in an ASP.NET application if I call
Assembly.GetExecutingAssembly(), can I determine that the current assembly
is a web application?JV wrote:
> Is there a way to determine that an assembly is running under an ASP.NET w
eb
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
You can check what class it's derived from, eg WinForm vs WebForm
JV,
I think a good way to test whether or not you are running in an ASP.NET
application is to access the static Current property on the HttpContext
class. If it is not running in ASP.NET, then the property should return
null.
Hope this helps.
- Nicholas Paldino [.NET/C# MVP]
- mvp@.spam.guard.caspershouse.com
"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
> web application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
Be aware if your solution doesn't have a reference to System.Web.dll, it
will throw an exception if you access System.Web.HttpContext.
bill
"Nicholas Paldino [.NET/C# MVP]" <mvp@.spam.guard.caspershouse.com> wrote in
message news:Olu$BMaJFHA.1172@.TK2MSFTNGP12.phx.gbl...
> JV,
> I think a good way to test whether or not you are running in an
ASP.NET
> application is to access the static Current property on the HttpContext
> class. If it is not running in ASP.NET, then the property should return
> null.
> Hope this helps.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@.spam.guard.caspershouse.com
> "JV" <johnNOSPAMme@.goisc.com> wrote in message
> news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
assembly
>
bill:
I think you meant to say "yield a compiler error", not "throw an
exception exception"...
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
<theman@.nameht.org> wrote:
>Be aware if your solution doesn't have a reference to System.Web.dll, it
>will throw an exception if you access System.Web.HttpContext.
>bill
>
Thanks for making me think about my response. <grin> I actually didn't
even mean exception, infact after reading my response, I think I just
randomly typed something in that sounded good...
Not all threads in a asp.net application have a HttpContext.Current attached
to it. You can use the HttpContext.Current if you want to know if the
calling thread ( current context) is currently processing a request through
the Http Pipeline, but it is not a reliable indicator that the calling
assembly is a windows application, or a web app. Timers, callbacks, user
created threads, etc will have a null value and can be from either.
Thanks for straightening me out Scott!
bill
"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:csd131dhjmjjeuh906jql1a5f1l1bepett@.
4ax.com...
> bill:
> I think you meant to say "yield a compiler error", not "throw an
> exception exception"...
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
> <theman@.nameht.org> wrote:
>
>
I have not tried this,
but instead of Assembly.GetExecutingAssembly(), try
Assembly.GetEntryAssembly()...
Greetings,
Henning Krause [MVP]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)
"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
web
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
Tuesday, March 13, 2012
System.Reflection
application as opposed to a Windows application?
For example, in an ASP.NET application if I call
Assembly.GetExecutingAssembly(), can I determine that the current assembly
is a web application?JV wrote:
> Is there a way to determine that an assembly is running under an ASP.NET web
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
>
You can check what class it's derived from, eg WinForm vs WebForm
JV,
I think a good way to test whether or not you are running in an ASP.NET
application is to access the static Current property on the HttpContext
class. If it is not running in ASP.NET, then the property should return
null.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@.spam.guard.caspershouse.com
"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
> web application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?
Be aware if your solution doesn't have a reference to System.Web.dll, it
will throw an exception if you access System.Web.HttpContext.
bill
"Nicholas Paldino [.NET/C# MVP]" <mvp@.spam.guard.caspershouse.com> wrote in
message news:Olu$BMaJFHA.1172@.TK2MSFTNGP12.phx.gbl...
> JV,
> I think a good way to test whether or not you are running in an
ASP.NET
> application is to access the static Current property on the HttpContext
> class. If it is not running in ASP.NET, then the property should return
> null.
> Hope this helps.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@.spam.guard.caspershouse.com
> "JV" <johnNOSPAMme@.goisc.com> wrote in message
> news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> > Is there a way to determine that an assembly is running under an ASP.NET
> > web application as opposed to a Windows application?
> > For example, in an ASP.NET application if I call
> > Assembly.GetExecutingAssembly(), can I determine that the current
assembly
> > is a web application?
bill:
I think you meant to say "yield a compiler error", not "throw an
exception exception"...
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
<theman@.nameht.org> wrote:
>Be aware if your solution doesn't have a reference to System.Web.dll, it
>will throw an exception if you access System.Web.HttpContext.
>bill
Thanks for making me think about my response. <grin> I actually didn't
even mean exception, infact after reading my response, I think I just
randomly typed something in that sounded good...
Not all threads in a asp.net application have a HttpContext.Current attached
to it. You can use the HttpContext.Current if you want to know if the
calling thread ( current context) is currently processing a request through
the Http Pipeline, but it is not a reliable indicator that the calling
assembly is a windows application, or a web app. Timers, callbacks, user
created threads, etc will have a null value and can be from either.
Thanks for straightening me out Scott!
bill
"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:csd131dhjmjjeuh906jql1a5f1l1bepett@.4ax.com...
> bill:
> I think you meant to say "yield a compiler error", not "throw an
> exception exception"...
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
> On Thu, 10 Mar 2005 14:08:08 -0600, "William F. Robertson, Jr."
> <theman@.nameht.org> wrote:
> >Be aware if your solution doesn't have a reference to System.Web.dll, it
> >will throw an exception if you access System.Web.HttpContext.
> >bill
I have not tried this,
but instead of Assembly.GetExecutingAssembly(), try
Assembly.GetEntryAssembly()...
Greetings,
Henning Krause [MVP]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)
"JV" <johnNOSPAMme@.goisc.com> wrote in message
news:OPATXEaJFHA.1280@.TK2MSFTNGP09.phx.gbl...
> Is there a way to determine that an assembly is running under an ASP.NET
web
> application as opposed to a Windows application?
> For example, in an ASP.NET application if I call
> Assembly.GetExecutingAssembly(), can I determine that the current assembly
> is a web application?