Dynamically loading the url of a web reference object in C#

Hi,
We have a number of assemblies (C# - VS 2010) that access third party web services via SOAP.  The url to access the site is part of the web reference object.
We have need to be able to change the url used to access the service at run runtime when conditions require.
What would the be the best practice of dynamically setting the url to be used at run time?
Thanks in advance.
SanDegan99

You could specify the URLs as keys in the application configuration file (App.config or web.config) of the main application:
https://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/aa374182(v=vs.85).aspx
App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="url1" value="http://www.url.com/test.asmx"/>
</appSettings>
</configuration>
You can then retrieve these values using the ConfigurationManager class in any assembly that is referenced from the main application like this (add a reference to System.Configuration.dll):
string url = System.Configuration.ConfigurationManager.AppSettings["url1"].ToString();
You can change the values of the keys in the application configuration file without having to recompile the application.
The other option is to specify the URLs in a database or some other persistent storage from which you read at runtime but configuration files are generally used to store these kind of variable application settings.
Please remember to mark helpful posts as answer to close your threads and remember that any new question you may have should be asked in a new thread of its own.

Similar Messages

  • ITSmobile service pass system/port/client dynamically in the URL

    Hi all,
        The ITSmobile service we have created redirects to another service in different server using ~redirectURL.
    so the ~redirectURL =  http://splhrd398.baplc.com:8005/sap/bc/gui/sap/its/zdemo_mobile?sap-client=150
    is there anyway to pass
    system : splhrd398.baplc.com ( This is the name of  the different server)
    port no: 8005
    sap-client=150
    dynamically in the URL.
    because when we transport the same to Testing and production. i need to know whether we have to do manually .
    If you have  any option to do  dynamically let me know.
    please throw some light,
    thanks  in advance
    Deepak

    Hi ,
    Create a technical system and bussienss system of type WEB AS ABAP and use this bussiness system for source system in XI and try it.
    Thanks & Regards,
    Sekhar

  • Hi! I need to load a GET url that si very long. On other browsers, I can load the url. In firefox 3.6, no. There is an addons or a plugin so I can extend this limit? If yes, is possible to load automatically this addons when loading a certain page? thanks

    Hi!
    I need to load a GET url that si very long. On other browsers, I can load the url. In firefox 3.6, no.
    There is an addons or a plugin so I can extend this limit? If yes, is possible to load automatically this addons when loading a certain page? thanks
    The url is sometingh like this (this is correctly loaded, but it could be longer)

    Firefox should have problems with long GET data appended to an URL (long would be over 64k).<br />
    If there are problems then it is possible that an extension is the cause of that.
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Link the URL to SAP web Lists

    hi,
    how to Link the URL to SAP web Lists using the ITS server
    please help me ASAP
    regards,
    vijay
    Message was edited by:
            vijay Aru

    to do this while writing the list you have to use WWW_SET_URL function.
    example
    write: 38(3) itab-ob color col_normal intensified off .
    url = 'http://www.google.com' .
        clear : leng .
        leng = 3 .
        call function 'WWW_SET_URL'
             exporting
                  offset        = 37
                  length        = leng
                  func          = url
             tables
                  query_string  = qstring
             exceptions
                  invalid_table = 1
                  others        = 2.
        if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
    Regards
    Raja

  • Problem in loading the WL6.1 Examples Web Applications

    While the server 6.1 is starting, an error message is displayed in the DOS window.
    19.10.2001 14:28:28 CEST> <Debug> <HTTP> <Could not resolve entity "-//BEA Systems, Inc.//DTD Web Application 6.1//EN". Check
    your dtd reference.>
    <19.10.2001 14:28:30 CEST> <Error> <HTTP> <[examplesWebApp] Error reading Web application "C:\bea\wlserver6.1\config\examples\a
    pplications\examplesWebApp"
    java.net.UnknownHostException: www.bea.com
    It sounds to be related with the web.xml file. I thank you by advance for your help.
    Cheers

    Hi there,
    Many thanks for your answer. I am fine but I am sure I will be even more fine
    when I solve this technical issue.
    I checked the weblogic.xml file as you suggested and it is OK.
    I even tried to access the URL "http://www.bea.com/servers/wls610/dtd/weblogic-web-jar.dtd"
    with IE5. I had some doubt regarding our corportate proxy. But it worked fine.
    I can access successfully the dtd with a browser. I really don't see what is going
    wrong. I attached in case of the weblogic.xml file for your examination.
    Here is an extract of the error message displayed in the DOS window.
    <23.10.2001 13:52:50 CEST> <Info> <J2EE> <Deployed : DefaultWebApp>
    <23.10.2001 13:52:50 CEST> <Info> <HTTP> <[HTTP examplesServer] Loading web app:
    examplesWebApp>
    <23.10.2001 13:52:50 CEST> <Info> <HTTP> <[examplesServer] Loading "examplesWebApp"
    from directory: "C:\bea\wlserver6.1\config\
    examples\applications\examplesWebApp">
    <23.10.2001 13:52:50 CEST> <Warning> <HTTP> <servlet DisplaySetToPage is referenced
    but not defined in web.xml>
    <23.10.2001 13:52:50 CEST> <Debug> <HTTP> <Could not resolve entity "//BEA Systems,
    Inc.//DTD Web Application 6.1//EN". Check y
    our dtd reference.>
    <23.10.2001 13:52:52 CEST> <Error> <HTTP> <[examplesWebApp] Error reading Web
    application "C:\bea\wlserver6.1\config\examples\a
    pplications\examplesWebApp"
    java.net.UnknownHostException: www.bea.com
    at java.net.InetAddress.getAllByName0(InetAddress.java:571)
    etc....
    Could the origin of my problem come from the aforementionned error message "<servlet
    DisplaySetToPage is referenced but not defined in web.xml>" ?
    I thank you once again by advance for your help and support.
    Cheers
    Athmani H.
    BEA Weblogic Support <[email protected]> wrote:
    Hi Athmani
    Greetings...!
    How are you doing?.
    Weblogic 6.1 examples web application, examplesWebApp, should have the
    below given DOCTYPE in the weblogic.xml.
    <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application
    6.1//EN"
    "http://www.bea.com/servers/wls610/dtd/weblogic-web-jar.dtd">
    Please check that.
    Thanks & Regards
    BEA Systems Supoport
    Athmani wrote:
    While the server 6.1 is starting, an error message is displayed inthe DOS window.
    19.10.2001 14:28:28 CEST> <Debug> <HTTP> <Could not resolve entity"-//BEA Systems, Inc.//DTD Web Application 6.1//EN". Check
    your dtd reference.>
    <19.10.2001 14:28:30 CEST> <Error> <HTTP> <[examplesWebApp] Error readingWeb application "C:\bea\wlserver6.1\config\examples\a
    pplications\examplesWebApp"
    java.net.UnknownHostException: www.bea.com
    It sounds to be related with the web.xml file. I thank you by advancefor your help.
    Cheers
    [weblogic.xml]

  • Dynamically loading the MathScript Node

    Hi - Is it possible to dynamically load script into the Mathscript Node at Run time. I see that you can use define functions and paths and things . But being a newbie to Mathscript could all this hang together to make dynamic loading a possibility and how?
    thanks dht 

    Hi,
      unfortunately the node doesn't support run-time dynamic loading of scripts. You can load variable values with the load function, but not scripts.
    http://zone.ni.com/reference/en-XX/help/371361A-01/lvtextmath/msfunc_load/
    http://zone.ni.com/reference/en-XX/help/371361A-01/lvhowto/saving_loading_scripts/
    Depending on your application, you could use a case statement to decide between several pre-built (and possibly compiled) mathscript nodes, and acheive the functionality that way.
    Another option might be to use the formula vi's instead, although this will require a more complex architecture to parse the text file you'd generate.
    For more information on MathScript, please see the following link
    http://zone.ni.com/devzone/devzoneweb.nsf/Opendoc?openagent&568C773718B080F286257096005BD314
    Hope that helps
    Sacha Emery
    National Instruments (UK)
    // it takes almost no time to rate an answer

  • When I open another Tab and type in a website address, after the site loads the URL in the navigation bar disappears. Why?

    When I open a new tab and type in the website url, after the website loads the website url disappears. In order for me to get it to come back, I have to right click on the navigation bar and click undo. why is this?

    Did this happen immediately after the reset or at a later time?
    Does this only happen on a new tab?
    What is the current setting for the new tab page as set via the browser.newtab.url pref?
    You can open the <b>about:config</b> page via the location bar.
    *http://kb.mozillazine.org/about:config
    Rename or delete the prefs.js file and possible numbered prefs-##.js and user.js files to reset all prefs to the default value.
    *http://kb.mozillazine.org/Preferences_not_saved
    *http://kb.mozillazine.org/Resetting_preferences

  • Safari 2.0.3 does not load the URL's I type

    Hello,
    can anyone help me? I have installed OS 10.4 with that came safari 2.0.3? OK!
    but now I cant load any URL that I type in my browser? It does work when I choose a bookmark. But thats all.
    Is this a common problem. Or has it something to see with the firewall at my job?
    help please...

    hello
    i am finding the same thing with safari.
    I click on a link on my own website and it says 'page not found on this server'. However I know the page is there because it is my own site! Also the site loads ok in Firefox.
    I get the same problem with images on some sites, they don't load however much I click refresh.
    I also get problems with this very site on Apple, I have to click a link several times before the browser loads it, otherwise it just sits there and hangs.
    When I first got Safari 2 I moved over from Firefox because Safari was faster. I don't know what Apple have done but they have thrashed a great product. I have now moved back to Firefox, using version 1.5 which is much better than the latest Safari.
    I am ashamed of Apple.

  • Dynamically passing the URL

    Hi
    In the receiver SOAP Adapter I got to send the Target URL ( Connection Parameters.....> Target URL) dynamically on the basis of URL that I get from payload. Is it possible to do this by using UDF ?? If so could you plz explain how we can do this ?? Plz point me it there are any materials/blogs/threads available on  this topic ??
    Regards
    kumar

    Hi palnati
    you can use Adapter Specific Identifiers and set the SOAP URL and SOAP Action dynamically.
    Here is the link for doc which can help u out :
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79
    look this thread also
    Setting interface name dynamically from client for SOAP Adapter...
    Regds
    Abhishek

  • How to find the URL of deployed Web services?

    Hi,guys. I have created a Web service, and deployed to WAS.But where is the accessing URL? WAS has created several WSDLs for the serviece, but I can not find the URL in the files.
    I think that the URL looks like "http://localhost:50000/XISOAPAdapter/MessageServlet?channel=:WAS2:CC_GIS_Equipment_Create_SOAPOUT&version=3.0&Sender.Service=WAS2&Interface=urn%3Azpepc%3Agis%3Aequipment%3Amaintenance%5EMI_GIS_Equipment_Create"

    my accessing code is:
    public class VacationClient {
         public static void main(String[] args) throws Exception {
              System.out.println("SOAP call start");
              VacationClient helloSOAPClient = new VacationClient();
              String resultValue = helloSOAPClient.doSOAPRequest(
                        "VacationCheckerService", "getVacationDays",
                        "employed_years", 20);
         public String doSOAPRequest(String _strURI, String _strMethodName,
                   String _strName, int _strValue) throws Exception {
              Call call = new Call();
              call.setTargetObjectURI("urn:" + _strURI);
              call.setMethodName(_strMethodName);
              call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
              Vector params = new Vector();
              params.addElement(new Parameter(_strName, Integer.class, new Integer(
                        _strValue), null));
              call.setParams(params);
              System.out.println("&#24320;&#22987;");
              Response resp = call
                        .invoke(
                                  new URL(
                                            "http://10.136.31.121:50000/TestWeb_Config1_SoapServlet"),
              if (resp.generatedFault()) {
                   Fault fault = resp.getFault();
                   System.out.println("failed&#65281;");
                   return "failed&#65281;";
              } else {
                   Parameter result = resp.getReturnValue();
                   System.out.println("sucessful&#65281;"+result.getValue().toString());
                   return result.getValue().toString();
    But the URL is not correct ,and an exception is throwed:
    Exception in thread "main" [SOAPException: faultCode=SOAP-ENV:Client; msg=Software caused connection abort: recv failed; targetException=java.net.SocketException: Software caused connection abort: recv failed]
         at org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.java:358)
         at org.apache.soap.rpc.Call.invoke(Call.java:248)
         at test.VacationClient.doSOAPRequest(VacationClient.java:44)
         at test.VacationClient.main(VacationClient.java:18)

  • Problem with dynamically loading the dropdown list from database

    Please help me,
    i am having a jsp page which contains a form
    with a textfield ,two dropdown list
    and a submit button
    when i select a list from first drop down, second drop down has to
    be loaded from the database dynamically according to the
    selected one in the first drop down.
    i gave onselect event for the first drop down and
    gave this one
    temp=first dropdown selected value
    self.location='currentfile+query='+temp;
    after this current page is reloading, but the already existing
    values in textfield and first selected value in drop down list is
    missing.
    how to solve this problem? and the rest of the problem. i mean
    loading the data into second drop down list.
    plz help me......

    in first <selcet> tag write Onchange and submit to the jsp then the values will return in second select box.

  • How to display the rows dynamically in the table display in web dynpro abap

    Hi experts,
                   There is a visible row count tab where you can give the no of rows to be displayed in the output table, but i want it to be done dynamically as the row count of my table may change dynamically at runtime.
    And i want to know how to reduce the width of a column as my table display is taking the length as per the binded table specifications.Can anyone please help me out in this issue.
    Thanks in advance,
    Anita.

    Hi Anita
    You can bind the visiblerowcount property to the a context attribute. and at runtime you can set the context attribute to the no of rows you want in your table,
    Regards
    Naresh

  • Dynamically load the Version info from maven

    Hello,
    I am working on a project which is managed by maven.
    I want to load the version info marked in project.xml(conf file for maven) from my swing app.
    One way is to generate a class holding a static attribute indicating Version using maven.
    Anyone has some other suggestions?
    Thanks in advance

    Hello,
    I am working on a project which is managed by maven.
    I want to load the version info marked in project.xml(conf file for maven) from my swing app.
    One way is to generate a class holding a static attribute indicating Version using maven.
    Anyone has some other suggestions?
    Thanks in advance

  • Where is the URL defined for web enabled transactions / PFCG execute?

    Hi
    One of our developers is having an issue. Apparently, when executing a web enabled transaction from within PFCG (in the menu structure right-click and choose u2018executeu2019) the Internet Explorer on the client is started with a url to:  http://www-s1pprint.ourcompany.com/sap/bc/webdynpro/.... which is incorrect (note our system SID is S3D but it was copied from S1P, however, what is the 'print' part??)
    When testing the exact same service from SICF it is working well and goes to the correct URL http://www.esd3002a.ourcompany.com/ etc, so the reference must come from another source. We'e checked parameters in SM59, RZ10 and SMICM so far and can't find anything relevant.
    Where is this set?
    Thanks
    Ross

    What's the content of the parameter
    icm/host_name_full
    (check using RZ11).
    Does this return the proper full qualified hostname? If yes,  check the hosts file and/or DNS of the server whether the IP resolves to the proper name and vice versa.
    Markus

  • Not able to access the URL for this web service (BPR)

    1. Start SAP Solution Manager and call transaction SICF.
    2. Right-click on default_host/sap/bc/solman, for example, and
    select Enable service. When the service is enabled, additional
    subgroups are visible.
    Enabling reveals the URI of the Web service. In this case, it is
    /sap/bc/solman/bpr. The protocol type is http. If you right-click
    on bpr and select Display service i got the below error
    <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding">
    <soap:Header/>
    u2212
    <soap:Body>
    u2212
    <soap:Fault>
    <soap:faultcode>Client</soap:faultcode>
    <soap:faultstring>Missing SOAP envelope.</soap:faultstring>
    </soap:Fault>
    </soap:Body>
    </soap:Envelop
    Regards,
    Neni

    Hello Neni,
    In most circumstances this error was caused by incorrect customizing, an external alias for the default host /sap/bc/solman/defaultuser had an incorrect target handler assigned to it.
    Solution Manager's IMG and documentation (www.service.sap.com/solutionmanager) should detail the correct
    value to use.
    The correct values can be maintained in SICF.
    On top of this, please review the following URL for external aliases documentation:
    http://help.sap.com/saphelp_sm40/helpdata/en/78/9852bdc06b11d4ad310000e83539c3/frameset.htm
    Thanks,
    Mark

Maybe you are looking for

  • Can't seem to make my Airport Express function

    I have a rather old Airport Express that I normally use to stream music. Every now and then I have to reset it but it works quite well. I brought it with me on a trip to South America but I can't get it to work. The AX flashes Amber, Airport Utility

  • Bridge CS6: Output to PDF not working/Blank

    Using Mac Mini: Lion OS. Adobe CS6 Photoshop / Bridge This Output worked in the past. Sometime in the last month it has stopped working. I select three images for examples and want to create a simple pdf (content sheet) Nothing fancy, no watermark. I

  • Trying to understand Java Sockets

    First, I have been able to find enough examples to get off ground zero and now I need a little help understanding what I have found. Secondly, I have a problem that i need a little help on. First - as I understand it the // indicates a comment and th

  • Enable save capability

    I have created a form in LiveCycle Designer, how do I enable the save capabilty on the form so that people opening it up in Adobe Reader are able to SAVE this form. I can get it to print, but not to save. In my travels I have read that the PDF author

  • Photo stacking with cs4

    Is there a facility to photo stack with cs4