简体   繁体   中英

How can I change a Web Service URL with out recompiling?

We have an web app that is talking to Netsuite via Netsuite's web services. We setup the Web Service via VS 2005's Add Web Reference wizard which generates all the proxy code.

Netsuite have sandbox accounts that allow testing (a different web reference URL). Ideally we want to hop back and forth between the live service and the test service. I am hoping that I can just change an xml file to point to the web service I want. The config file contains

    <Netsuite.Properties.Settings>
        <setting name="Netsuite_com_netsuite_webservices_v21_NetSuiteService"
            serializeAs="String">
            <value>https://webservices.netsuite.com/services/NetSuitePort_2008_2</value>
        </setting>
    </Netsuite.Properties.Settings>

but the web reference URL is https://webservices.netsuite.com/wsdl/v2008_2_0/netsuite.wsdl

Has anyone tried this and know how to do this?

I do this frequently with NetSuite integration appls without needing to recompile. Swap out your service value in your config file to

https://webservices.sandbox.netsuite.com/services/NetSuitePort_2008_2

if you were using this value for production:

h ttps://webservices.netsuite.com/services/NetSuitePort_2008_2

You could put the WebService URL in the web.config (or AppSettings.config) file and then set it at runtime.

wsProxy proxy = new wsProxy();
wsProxy.Url = ConfigurationManager.AppSettings.Get("WebserviceUrl");
wsProxy.DoSomething();

This will allow you to change the WebService URL without recompiling the application.

Can't test in VS2005, but I know in 2008 when you deploy a web application, it puts the service URI in the Settings.settings file in the Properties directory. You can alter the URI to point to the test instance of the service there and restart the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM