Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have given my web service path from Web.config key, but the problem is when I update the WebService the path gets changed.

So, how can I prevent this scenario?
This is what I have given so far in Reference.cs.
C#
public ABC()
{
    this.Url = System.Configuration.ConfigurationManager.AppSettings["ABC"];
    if ((this.IsLocalFileSystemWebService(this.Url) == true))
    {
        this.UseDefaultCredentials = true;
        this.useDefaultCredentialsSetExplicitly = false;
    }
    else
    {
        this.useDefaultCredentialsSetExplicitly = true;
    }
}


I got this from this link How to make your Web Reference proxy URL dynamic[^]

But whenever I update the WebService it gets changed to.
C#
public ABC() 
{
    this.Url = global::Drd.Properties.Settings.Default.CoreBusiness_UbossProvisioning_ABC;
    if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
        this.UseDefaultCredentials = true;
        this.useDefaultCredentialsSetExplicitly = false;
    }
    else {
        this.useDefaultCredentialsSetExplicitly = true;
    }
}
Posted
v5
Comments
Kornfeld Eliyahu Peter 30-Sep-13 9:48am    
Did you changed URL Behavior to dynamic?
Arjun Menon U.K 30-Sep-13 9:53am    
yes :(

Service references changes every time if you are hosting the service in the local server.
If you want that to be static you need to deploy your service on the server or specify specific Port number to that. In that way you can restrict that to change dynamically.

Hope this will help you. Let me know if that doesnt work.

- SG
 
Share this answer
 
Comments
Arjun Menon U.K 30-Sep-13 9:39am    
web service is not a local host...its in a separate server...
that address is specified in the web config key...
I hope what am telling is the answer to ur question : )
than wht i think is u just need to add the proxy of the service. You dont have to read that from the webconfig. Just add the service reference and that will automatically update the web config.

This is wht i understand from the reference you have given.

Instead of using from the webconfig just use the object your service and use that.
 
Share this answer
 
v2
Comments
Arjun Menon U.K 30-Sep-13 10:05am    
object of service means??
Please improve your previous answer, don't add multiple solutions. Please delete this.

Thanks,
Tadit
Refrence.cs is a generated file so changing it at any time is bad practice (see file header)

Refreshing web reference is regenerating this file according its properties. You got the code you see because your URL Behaviour is dynamic.

The code you see means that in your web.config file there is a part reads somesing like this:

XML
<applicationsettings>
   <drd.properties.settings>
        <setting name="CoreBusiness_UbossProvisioning_ABC" serializeas="String">
            <value>your service url goes here</value>
        </setting>
    </drd.properties.settings>
</applicationsettings>


If you want to change the url you should do it in the web.config file...

Regards
Peter
 
Share this answer
 
Comments
Arjun Menon U.K 1-Oct-13 1:00am    
so if i put the url in webconfig file and i remove the thing you mentioned above, it will work?
Kornfeld Eliyahu Peter 1-Oct-13 1:07am    
The best is to let VS generate the code for you and after it just do changes to the web.config file. That should do the trick...
Arjun Menon U.K 1-Oct-13 1:08am    
Its there in appconfig file. I removed the key and when i updated it , it still getting changed to the
global::Drd.Properties.Settings.Default.CoreBusiness_UbossProvisioning_ABC;
Kornfeld Eliyahu Peter 1-Oct-13 1:17am    
It's all right. You should go now to your app.config, find the setting called CoreBusiness_UbossProvisioning_ABC and edit it's value to the url you want!
Arjun Menon U.K 1-Oct-13 10:49am    
the reason i did so is that we don't have to stop the running site so as to change the url. Since the app config exists , applying the url won't do my job, i guess... :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900