Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you pull the URL for an ASP.NET web reference from a configuration file in Visual Studio 2008?

Tags:

asmx

I have a web reference for our report server embedded in our application. The server that the reports live on could change though, and I'd like to be able to change it "on the fly" if necessary.

I know I've done this before, but can't seem to remember how. Thanks for your help.

I've manually driven around this for the time being. It's not a big deal to set the URL in the code, but I'd like to figure out what the "proper" way of doing this in VS 2008 is. Could anyone provide any further insights? Thanks!


In VS2008 when I change the URL Behavior property to Dynamic I get the following code auto-generated in the Reference class.

Can I override this setting (MySettings) in the web.config? I guess I don't know how the settings stuff works.

Public Sub New()
    MyBase.New
    Me.Url = Global.My.MySettings.Default.Namespace_Reference_ServiceName
    If (Me.IsLocalFileSystemWebService(Me.Url) = true) Then
        Me.UseDefaultCredentials = true
        Me.useDefaultCredentialsSetExplicitly = false
    Else
        Me.useDefaultCredentialsSetExplicitly = true
    End If
End Sub

EDIT

So this stuff has changed a bit since VS03 (which was probably the last VS version I used to do this).

According to: http://msdn.microsoft.com/en-us/library/a65txexh.aspx it looks like I have a settings object on which I can set the property programatically, but that I would need to provide the logic to retrieve that URL from the web.config.

Is this the new standard way of doing this in VS2008, or am I missing something?

EDIT #2

Anyone have any ideas here? I drove around it in my application and just put the URL in my web.config myself and read it out. But I'm not happy with that because it still feels like I'm missing something.

like image 830
Ian Robinson Avatar asked Aug 07 '08 19:08

Ian Robinson


People also ask

How do I add a Web service reference in Visual Studio?

You can also open the Add Web Reference dialog box in the Solution Explorer pane by right-clicking References and selecting Add Web Reference. In the Web reference name box, rename the Web reference toExcelWebService. Click Add Reference to add a Web reference for the target Web service.

Where is web config file in Visual Studio?

config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ folder. The default settings that are contained in the Machine.

How do I add a web reference in Visual Studio 2010?

To add a Web reference to a project. In Solution Explorer, right-click the name of the project to add the Web service to and then click Add Web Reference. The Add Web Reference dialog box is displayed. In the URL box, enter the URL of the Web service to use.


1 Answers

In the properties window change the "behavior" to Dynamic.

See: http://www.codeproject.com/KB/XML/wsdldynamicurl.aspx

like image 92
brendan Avatar answered Oct 04 '22 16:10

brendan