webservice problem: The underlying connection was closed: Unable to connect to the remote server


F

Frasse

Hello All!

I also have the unfamous error described in subject. I created the
HelloWorld webservice simplest way by uncommenting the HelloWorld
source. I then create a client with the following code


Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim ws As New Service1
Try
MsgBox(ws.HelloWorld())
Catch ex As Exception
MsgBox(ex.ToString())
End Try

End Sub
End Class


I then place the HelloWorld.EXE in wwwroot and executes the EXE from
another PC on intranet with a URL like "http://pc165/HelloWorld.EXE".
The client fails with exception:

System.Net.WebException: The underlying connection was closed: Unable
to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at HelloWorld.localhost.Service1.HelloWorld()
at HelloWorld.Form1.Button1_Click(Object sender, EventArgs e)


Please help, Im really stuck on this one!
 
Ad

Advertisements

J

Jan Tielens

How did you create the web reference, if you created it using the url
http://localhost/xxx/service.asmx the problem could be that if you run the
app from another computer, it tries to find the webserive on that computer
too. To solve this you could change the localhost part with the name of the
server the web service is located. Or you can set the URLBehavior of the web
reference to dynamic, so the settings are stored in the app.config.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
F

Frasse

That's it! !!

I thought it was enough to change the URL in the "Add Web Reference"
dialog from "http://localhost/..." to "http://pc165/...". I now see
that that is not the case. I must change the URL in Reference.vb
afterwards.

This is a big relief! Thanks Jan!


Jan Tielens said:
How did you create the web reference, if you created it using the url
http://localhost/xxx/service.asmx the problem could be that if you run the
app from another computer, it tries to find the webserive on that computer
too. To solve this you could change the localhost part with the name of the
server the web service is located. Or you can set the URLBehavior of the web
reference to dynamic, so the settings are stored in the app.config.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Frasse said:
Hello All!

I also have the unfamous error described in subject. I created the
HelloWorld webservice simplest way by uncommenting the HelloWorld
source. I then create a client with the following code


Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim ws As New Service1
Try
MsgBox(ws.HelloWorld())
Catch ex As Exception
MsgBox(ex.ToString())
End Try

End Sub
End Class


I then place the HelloWorld.EXE in wwwroot and executes the EXE from
another PC on intranet with a URL like "http://pc165/HelloWorld.EXE".
The client fails with exception:

System.Net.WebException: The underlying connection was closed: Unable
to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at HelloWorld.localhost.Service1.HelloWorld()
at HelloWorld.Form1.Button1_Click(Object sender, EventArgs e)


Please help, Im really stuck on this one!
 
Ad

Advertisements

J

Jan Tielens

You're welcome! :)

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Frasse said:
That's it! !!

I thought it was enough to change the URL in the "Add Web Reference"
dialog from "http://localhost/..." to "http://pc165/...". I now see
that that is not the case. I must change the URL in Reference.vb
afterwards.

This is a big relief! Thanks Jan!


"Jan Tielens" <[email protected]> wrote in message
How did you create the web reference, if you created it using the url
http://localhost/xxx/service.asmx the problem could be that if you run the
app from another computer, it tries to find the webserive on that computer
too. To solve this you could change the localhost part with the name of the
server the web service is located. Or you can set the URLBehavior of the web
reference to dynamic, so the settings are stored in the app.config.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


Frasse said:
Hello All!

I also have the unfamous error described in subject. I created the
HelloWorld webservice simplest way by uncommenting the HelloWorld
source. I then create a client with the following code


Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim ws As New Service1
Try
MsgBox(ws.HelloWorld())
Catch ex As Exception
MsgBox(ex.ToString())
End Try

End Sub
End Class


I then place the HelloWorld.EXE in wwwroot and executes the EXE from
another PC on intranet with a URL like "http://pc165/HelloWorld.EXE".
The client fails with exception:

System.Net.WebException: The underlying connection was closed: Unable
to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at HelloWorld.localhost.Service1.HelloWorld()
at HelloWorld.Form1.Button1_Click(Object sender, EventArgs e)


Please help, Im really stuck on this one!
 

Top