Change url for webservice

Discussion in 'ASP .Net Web Services' started by Roland Wolters, Dec 1, 2003.

  1. Hi,

    My WebSite uses a webservice to get some data. Problem is that the url for
    the webservice is different when it is running on de webserver than when it
    is running localy, when it is built.

    When the website needs the webservice I read the correct url from the
    config file and change the url property. That works fine. That is, the
    first time I get an error. Of course I can catch the error but how can I
    prevent this?

    Here is the code:

    SiteDataService.SiteData objSiteData=new SiteDataService.SiteData();
    objSiteData.Url=ConfigurationSettings.AppSettings["WebServiceURL"];

    The first time these lines run it throws an error "The underlying
    connection was closed: An unexpected error occurred on a send" wich is
    correct because the url in the build is not a public url.

    How can I do this in a correct way?

    Greetings,



    Roland
    Roland Wolters, Dec 1, 2003
    #1
    1. Advertising

  2. have you used Visual Studio to build the web reference?
    Did you specify a "dynamic URL" for the web service?
    http://msdn.microsoft.com/library/en-us/vsintro7/html/vxconWebReferences.asp

    Even if you did not use VS, you can modify your code to set the URL on the
    service proxy, before the first call.
    Or, you could modify the generated proxy to reference the web.config file.

    -D


    "Roland Wolters" <> wrote in message
    news:Xns9444C712D8BE5woltersictnl@207.46.248.16...
    > Hi,
    >
    > My WebSite uses a webservice to get some data. Problem is that the url for
    > the webservice is different when it is running on de webserver than when

    it
    > is running localy, when it is built.
    >
    > When the website needs the webservice I read the correct url from the
    > config file and change the url property. That works fine. That is, the
    > first time I get an error. Of course I can catch the error but how can I
    > prevent this?
    >
    > Here is the code:
    >
    > SiteDataService.SiteData objSiteData=new SiteDataService.SiteData();
    > objSiteData.Url=ConfigurationSettings.AppSettings["WebServiceURL"];
    >
    > The first time these lines run it throws an error "The underlying
    > connection was closed: An unexpected error occurred on a send" wich is
    > correct because the url in the build is not a public url.
    >
    > How can I do this in a correct way?
    >
    > Greetings,
    >
    >
    >
    > Roland
    Dino Chiesa [Microsoft], Dec 2, 2003
    #2
    1. Advertising

  3. Hi,

    Yes I use VS to build the web referace and it is set to dynamic so the
    url for the webservice is specified in the web.config file.

    Every time however when the page is trying to access the webservice the
    FIRST time, it fails throwing the execption mentioned. When I simple
    reload the page it runs fine. At this time I am using a work-around
    where I try-catch the exception and retry it in the catch clause. This
    works fine but feels ugly.

    What to do?


    Thanx,

    ROland

    "Dino Chiesa [Microsoft]" <> wrote in
    news::

    > have you used Visual Studio to build the web reference?
    > Did you specify a "dynamic URL" for the web service?
    > http://msdn.microsoft.com/library/en-us/vsintro7/html/vxconWebReference
    > s.asp
    >
    > Even if you did not use VS, you can modify your code to set the URL on
    > the service proxy, before the first call.
    > Or, you could modify the generated proxy to reference the web.config
    > file.
    >
    > -D
    >
    >
    > "Roland Wolters" <> wrote in message
    > news:Xns9444C712D8BE5woltersictnl@207.46.248.16...
    >> Hi,
    >>
    >> My WebSite uses a webservice to get some data. Problem is that the
    >> url for the webservice is different when it is running on de
    >> webserver than when

    > it
    >> is running localy, when it is built.
    >>
    >> When the website needs the webservice I read the correct url from the
    >> config file and change the url property. That works fine. That is,
    >> the first time I get an error. Of course I can catch the error but
    >> how can I prevent this?
    >>
    >> Here is the code:
    >>
    >> SiteDataService.SiteData objSiteData=new
    >> SiteDataService.SiteData();
    >> objSiteData.Url=ConfigurationSettings.AppSettings["WebServiceURL"];
    >>
    >> The first time these lines run it throws an error "The underlying
    >> connection was closed: An unexpected error occurred on a send" wich
    >> is correct because the url in the build is not a public url.
    >>
    >> How can I do this in a correct way?
    >>
    >> Greetings,
    >>
    >>
    >>
    >> Roland

    >
    >
    >
    Roland Wolters, Dec 2, 2003
    #3
  4. Roland,
    I think the problem may be that you are timing out on the
    first call to the Web Service. The default timeout is 10
    seconds (at least it is in unmanaged code and I think it's
    the same). If you set your timeout to something like 60
    seconds that should handle the first call

    Jeremy

    >-----Original Message-----
    >Hi,
    >
    >Yes I use VS to build the web referace and it is set to

    dynamic so the
    >url for the webservice is specified in the web.config

    file.
    >
    >Every time however when the page is trying to access the

    webservice the
    >FIRST time, it fails throwing the execption mentioned.

    When I simple
    >reload the page it runs fine. At this time I am using a

    work-around
    >where I try-catch the exception and retry it in the catch

    clause. This
    >works fine but feels ugly.
    >
    >What to do?
    >
    >
    >Thanx,
    >
    >ROland
    >
    >"Dino Chiesa [Microsoft]" <>

    wrote in
    >news::
    >
    >> have you used Visual Studio to build the web reference?
    >> Did you specify a "dynamic URL" for the web service?
    >> http://msdn.microsoft.com/library/en-

    us/vsintro7/html/vxconWebReference
    >> s.asp
    >>
    >> Even if you did not use VS, you can modify your code to

    set the URL on
    >> the service proxy, before the first call.
    >> Or, you could modify the generated proxy to reference

    the web.config
    >> file.
    >>
    >> -D
    >>
    >>
    >> "Roland Wolters" <> wrote in

    message
    >> news:Xns9444C712D8BE5woltersictnl@207.46.248.16...
    >>> Hi,
    >>>
    >>> My WebSite uses a webservice to get some data. Problem

    is that the
    >>> url for the webservice is different when it is running

    on de
    >>> webserver than when

    >> it
    >>> is running localy, when it is built.
    >>>
    >>> When the website needs the webservice I read the

    correct url from the
    >>> config file and change the url property. That works

    fine. That is,
    >>> the first time I get an error. Of course I can catch

    the error but
    >>> how can I prevent this?
    >>>
    >>> Here is the code:
    >>>
    >>> SiteDataService.SiteData objSiteData=new
    >>> SiteDataService.SiteData();
    >>> objSiteData.Url=ConfigurationSettings.AppSettings

    ["WebServiceURL"];
    >>>
    >>> The first time these lines run it throws an error "The

    underlying
    >>> connection was closed: An unexpected error occurred on

    a send" wich
    >>> is correct because the url in the build is not a

    public url.
    >>>
    >>> How can I do this in a correct way?
    >>>
    >>> Greetings,
    >>>
    >>>
    >>>
    >>> Roland

    >>
    >>
    >>

    >
    >.
    >
    Jeremy Kercheval, Dec 2, 2003
    #4
  5. So do you have the proper URL in the web.config, or not?
    If so you don't need to change it. (as you suggest in the subject of your
    post).



    "Jeremy Kercheval" <> wrote in message
    news:b43401c3b8f1$5d946020$...
    > Roland,
    > I think the problem may be that you are timing out on the
    > first call to the Web Service. The default timeout is 10
    > seconds (at least it is in unmanaged code and I think it's
    > the same). If you set your timeout to something like 60
    > seconds that should handle the first call
    >
    > Jeremy
    >
    > >-----Original Message-----
    > >Hi,
    > >
    > >Yes I use VS to build the web referace and it is set to

    > dynamic so the
    > >url for the webservice is specified in the web.config

    > file.
    > >
    > >Every time however when the page is trying to access the

    > webservice the
    > >FIRST time, it fails throwing the execption mentioned.

    > When I simple
    > >reload the page it runs fine. At this time I am using a

    > work-around
    > >where I try-catch the exception and retry it in the catch

    > clause. This
    > >works fine but feels ugly.
    > >
    > >What to do?
    > >
    > >
    > >Thanx,
    > >
    > >ROland
    > >
    > >"Dino Chiesa [Microsoft]" <>

    > wrote in
    > >news::
    > >
    > >> have you used Visual Studio to build the web reference?
    > >> Did you specify a "dynamic URL" for the web service?
    > >> http://msdn.microsoft.com/library/en-

    > us/vsintro7/html/vxconWebReference
    > >> s.asp
    > >>
    > >> Even if you did not use VS, you can modify your code to

    > set the URL on
    > >> the service proxy, before the first call.
    > >> Or, you could modify the generated proxy to reference

    > the web.config
    > >> file.
    > >>
    > >> -D
    > >>
    > >>
    > >> "Roland Wolters" <> wrote in

    > message
    > >> news:Xns9444C712D8BE5woltersictnl@207.46.248.16...
    > >>> Hi,
    > >>>
    > >>> My WebSite uses a webservice to get some data. Problem

    > is that the
    > >>> url for the webservice is different when it is running

    > on de
    > >>> webserver than when
    > >> it
    > >>> is running localy, when it is built.
    > >>>
    > >>> When the website needs the webservice I read the

    > correct url from the
    > >>> config file and change the url property. That works

    > fine. That is,
    > >>> the first time I get an error. Of course I can catch

    > the error but
    > >>> how can I prevent this?
    > >>>
    > >>> Here is the code:
    > >>>
    > >>> SiteDataService.SiteData objSiteData=new
    > >>> SiteDataService.SiteData();
    > >>> objSiteData.Url=ConfigurationSettings.AppSettings

    > ["WebServiceURL"];
    > >>>
    > >>> The first time these lines run it throws an error "The

    > underlying
    > >>> connection was closed: An unexpected error occurred on

    > a send" wich
    > >>> is correct because the url in the build is not a

    > public url.
    > >>>
    > >>> How can I do this in a correct way?
    > >>>
    > >>> Greetings,
    > >>>
    > >>>
    > >>>
    > >>> Roland
    > >>
    > >>
    > >>

    > >
    > >.
    > >
    Dino Chiesa [Microsoft], Dec 4, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon paugh
    Replies:
    1
    Views:
    655
  2. batista
    Replies:
    1
    Views:
    885
    Laurent Bugnion
    Jan 26, 2006
  3. batista
    Replies:
    0
    Views:
    544
    batista
    Jan 26, 2006
  4. guenther schoebel
    Replies:
    2
    Views:
    6,458
    Eric Cartman
    Oct 10, 2003
  5. Just D.
    Replies:
    0
    Views:
    388
    Just D.
    Aug 11, 2004
Loading...

Share This Page