WEBSERVICE path changes in the deployment phase

There are two ways I know about using WebService in .NET:

First, proxy mode
The proxy mode is to first reference the WebService in the project to generate a proxy, Then operate this proxy to achieve the purpose of calling WebService.

However, in the development phase, because the WebService is referenced and the proxy is created, the WebService has a path. Then after the actual deployment, the path is different from the development phase. What should I do?

Handle it like this:

string servicepath = ConfigurationManager.AppSettings["ServicePath"];//Read the WebService path from the configuration fileBinding httpBinding = new  BasicHttpBinding();EndpointAddress httpAddress = new EndpointAddress(servicepath);SmsServiceClient proxy = n

Second, direct access
direct Access service address

using (WebClient webClient = new WebClient ()){ webClient.Encoding = Encoding.GetEncoding("utf-8"); string url = ConfigurationManager.AppSettings["ServicePath"];//Read the WebService path from the configuration file; string re = webClient.DownloadString(url);}

Leave a Comment

Your email address will not be published.