Web service address is changed

A

A.M

Hi,



I had a web server contained a web service.

We had to change the web server computer; so all client proxies must point
to new web server. My understanding is we have to compile all client
applications again.

We will probably change the address of web server in future again.



Is there any way that client applications programatically change the address
of web service in the proxy? I am thinking to have the address in
app.config, so we don't have to compile all client application any time that
we change the address of web server.



Thanks,

Alan
 
S

Scott Allen

Hi Alan:

In the Solution Explorer window, highlight the reference to the web
service under the Web References node, then view the properties.
Change the URL Behavior property from Static to Dynamic.

The web service proxy will now read the URL from web.config. Looking
in web.config you should see the IDE made an entry looking like:

<add key="WebApp.localhost.Service1"
value=http://server/WebService/Service1.asmx
/>

Now you can change the endpoint without a recompile.

HTH,
 
S

Steven Cheng[MSFT]

Thanks for Scott's suggestion.

Hi Alan,

As Scott has mentioned, we can dynamically change the webservice's client
proxy class's target url(asmx file's url). We can dig into the client proxy
class(WSDL.EXE generate for us)'s code, you'll find the class is something
like:

public class MyService :
System.Web.Services.Protocols.SoapHttpClientProtocol {

/// <remarks/>
public MyService() {
this.Url = "http://sha-schang-01/myservice/myservice.asmx";
}
.......


And the "Url" property is just the one we need to update when the
webservice's deployment server changed.

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.)
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top