How to pass a string value to: localhost.IDataCollectionservice()

Hello,

I have an App I wrote that needs to be dynamic in the localhost.IDataCollectionservice() I use for each install.

Private ws As New localhost.IDataCollectionservice()

ws.Url = "http://fs011/datacollection/isapi_dcwebservice.dll/soap/IDataCollection"

I have a function that will retrieve a filepath string, but I need to send this result into the following web service definition for it's URL path.  Here's an example of two paths for two different machines.  I need to insert the machine name and folder into this URL definition setting.

What I need to be dynamic is the macine name(fso11 and morr-2 in the two paths below) as well as the folder names where the web service is installed (DataCollection and Training in my two samples).

ws.Url = "http://fs011/datacollection/isapi_dcwebservice.dll/soap/IDataCollection"
'ws.Url = "http://morr-2/Training/isapi_dcwebservice.dll/soap/IDataCollection"

Thanks,
JMO9966
JMO9966Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulHewsCommented:
If this is VS 2005, you can set the web service UrlBehaviour property to Dynamic.  This will cause the setting to be saved in your App.Config which can be changed with a text editor, even when your program is deployed.

If VS 2003, you can still save and load from App.Config, but you will need to use appSettings:

Add a new item to your project and select the type "Application Configuration"

Edit the new App.Config so that you have the following information:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
      <add key="machine" value="fs011" />
      <add key="folder" value="datacollection" />
</appSettings>
</configuration>

Now you can use code like the following:


Dim Machine As String = Configuration.ConfigurationSettings.AppSettings.Get("machine")
Dim Folder As String = Configuration.ConfigurationSettings.AppSettings.Get("folder")
ws.Url = String.Format("http://{0}/{1}/isapi_dcwebservice.dll/soap/IDataCollection", Machine, Folder)

Open in new window

0
JMO9966Author Commented:
Thanks I run 2005 and am not clear on which of your code snippets to use and which to ignore.

I will check the Dynamic property you referred to.

Thanks,
JMO9966
0
PaulHewsCommented:
With Url Behavior = Dynamic, you won't have to use code at all.  The generated file will automatically read the URL from the .config file.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

JMO9966Author Commented:
Thanks, how do I set the URL to Dynamic?

JMO9966
0
PaulHewsCommented:
Click on the Web Reference in the Project Explorer window.  Now in the properties window, you'll see the "Url Behavior" property dropdown.  Change it to "Dynamic"  Now you'll be able to change the value in your app.config file.
0
JMO9966Author Commented:
Okay, my Web Reference as set to Dynamic.

Now I'm wondering how to changd the value in my App.config file.  I see your code with Get value.

Seems to be that I will first Set and then Get, but I'll have to figure out how to Set the value too.

Dim Machine As String = Configuration.ConfigurationSettings.AppSettings.Set("machine")
Dim Folder As String = Configuration.ConfigurationSettings.AppSettings.Set("folder")
ws.Url = String.Format("http://{0}/{1}/isapi_dcwebservice.dll/soap/IDataCollection", Machine, Folder)
 
Am I on the right track?

Thanks,
JMO9966
0
JMO9966Author Commented:
Increasing points too.
0
PaulHewsCommented:
Since you are using VS 2005, and you are not setting the URL property using a text editor, you can use My.Settings to set and retrieve the settings you want...

Go into your project properties, and select the Settings tab.  Create two new User level string settings using the settings dialog named Machine and Folder.  Now you can retrieve these settings like this:

ws.Url = String.Format("http://{0}/{1}/isapi_dcwebservice.dll/soap/IDataCollection", My.Settings.Machine, My.Settings.Folder)

Using My.Settings in VS2005
http://msdn2.microsoft.com/en-us/library/ms379611(VS.80).aspx

Change User Settings
http://msdn2.microsoft.com/en-us/library/shytyc55.aspx

Persist User Settings
http://msdn2.microsoft.com/en-us/library/fwc80dzb.aspx


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JMO9966Author Commented:
Thank You!

I'll give that a try.

JMO9966
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.