Change url for webservice

R

Roland Wolters

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
 
R

Roland Wolters

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

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 said:
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
 
J

Jeremy Kercheval

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

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


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

.
 
D

Dino Chiesa [Microsoft]

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 said:
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

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


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

.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top