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

Discussion in 'ASP .Net Web Services' started by Frasse, Feb 10, 2004.

  1. Frasse

    Frasse Guest

    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!
     
    Frasse, Feb 10, 2004
    #1
    1. Advertisements

  2. Frasse

    Jan Tielens Guest

    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
     
    Jan Tielens, Feb 12, 2004
    #2
    1. Advertisements

  3. Frasse

    Frasse Guest

    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!


     
    Frasse, Feb 12, 2004
    #3
  4. Frasse

    Jan Tielens Guest

    You're welcome! :)

    --
    Greetz

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


     
    Jan Tielens, Feb 13, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.