Changes Webservice's "Web Reference URL" added by add web reference [closed]

-1

I wonder if it would be possible and how to do this change by picking up the web.config address

    
asked by anonymous 05.07.2018 / 14:14

2 answers

1

Web.config

Within the tag add your new url to the Web Reference.

<appSettings>
    <add key="urlWebService" value="http://www.google.com" />
</appSettings>

When you instantiate the proxy class of your Web Service, change the URL to the url registered in web.config:

using (var webService = new Foo.WebService())
{
    webService.Url = ConfigurationManager.AppSettings["urlWebService"];
}

Do not forget that the names I used (google site, Foo.WebService) are fictitious names, as I do not know the name of your project templates.

    
05.07.2018 / 15:10
0

You need to create an instance of the class you want to use generated by the WebReference proxy classes. I'll give you an example using the WebService of the post office.

It can be accessed using the link below: link

After adding the reference of your WebService, instancie and class and see the Url property.

 br.com.correios.ws.CalcPrecoPrazoWS client = new br.com.correios.ws.CalcPrecoPrazoWS();

 string valorUrl = client.Url;
    
05.07.2018 / 14:57