473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Conditional Web Service instantiation

I work in a shop with up to three environments for the development/deployment
process. Each environment has its own db and web servers and its own web
services servers as well.

I am developing a .NET component as part of the application that calls one
of the web services for some of its functionailty. Currently, I have to
update the web service reference for the dev environment, compile the
component and deploy to the dev web server for testing/debug. Then, once the
code has been tested and debugged, before we can deploy it to the demo
environment I hate to change the URL for the web service, and recompile the
code to create a new install package for the demo environment. Then, for
changes and fixes, I have to change the web service URL back to the dev
environment and recompile the code and reinstall on the dev server.

If this was a windows app, I know we can control the web service url ion the
app.config file. However, my testing seems to indicate that does not work for
a component (DLL).

Is there some easier way to handle this so that I can code teh component
with both URLs and let it decide which webs service to call at runtime?

Aug 28 '07 #1
4 1816
"John Beschler" <Jo**********@discussions.microsoft.comwrote in message
news:D4**********************************@microsof t.com...
>I work in a shop with up to three environments for the
development/deployment
process. Each environment has its own db and web servers and its own web
services servers as well.

I am developing a .NET component as part of the application that calls one
of the web services for some of its functionailty. Currently, I have to
update the web service reference for the dev environment, compile the
component and deploy to the dev web server for testing/debug. Then, once
the
code has been tested and debugged, before we can deploy it to the demo
environment I hate to change the URL for the web service, and recompile
the
code to create a new install package for the demo environment. Then, for
changes and fixes, I have to change the web service URL back to the dev
environment and recompile the code and reinstall on the dev server.

If this was a windows app, I know we can control the web service url ion
the
app.config file. However, my testing seems to indicate that does not work
for
a component (DLL).

Is there some easier way to handle this so that I can code teh component
with both URLs and let it decide which webs service to call at runtime?
One way would be for the component to expose a Url property. This property
could set the Url of the proxy class.

Another thing would be for the component to require a particular appSettings
key in the .config file of the application that uses the component.

Finally, if you are using .NET 2.0, then I've heard that using the new
Settings architecture will resolve this problem for you. In that case, the
component itself would hold the definitions of the settings, along with
their default values. If the setting existed in a config file, then it would
be used, otherwise, it would be created when the component settings are
persisted.

Caveat: I haven't tried this myself with a component.
--
John Saunders [MVP]

Aug 28 '07 #2
John,

Thanks for the reply. I had actually considered using a property to select
which URL; however, I was unable to figure out a way to create the reference.
Could you point me to some examples of how to do this?

Thanks,
John Beschler
"John Saunders [MVP]" wrote:
"John Beschler" <Jo**********@discussions.microsoft.comwrote in message
news:D4**********************************@microsof t.com...
I work in a shop with up to three environments for the
development/deployment
process. Each environment has its own db and web servers and its own web
services servers as well.

I am developing a .NET component as part of the application that calls one
of the web services for some of its functionailty. Currently, I have to
update the web service reference for the dev environment, compile the
component and deploy to the dev web server for testing/debug. Then, once
the
code has been tested and debugged, before we can deploy it to the demo
environment I hate to change the URL for the web service, and recompile
the
code to create a new install package for the demo environment. Then, for
changes and fixes, I have to change the web service URL back to the dev
environment and recompile the code and reinstall on the dev server.

If this was a windows app, I know we can control the web service url ion
the
app.config file. However, my testing seems to indicate that does not work
for
a component (DLL).

Is there some easier way to handle this so that I can code teh component
with both URLs and let it decide which webs service to call at runtime?

One way would be for the component to expose a Url property. This property
could set the Url of the proxy class.

Another thing would be for the component to require a particular appSettings
key in the .config file of the application that uses the component.

Finally, if you are using .NET 2.0, then I've heard that using the new
Settings architecture will resolve this problem for you. In that case, the
component itself would hold the definitions of the settings, along with
their default values. If the setting existed in a config file, then it would
be used, otherwise, it would be created when the component settings are
persisted.

Caveat: I haven't tried this myself with a component.
--
John Saunders [MVP]

Aug 28 '07 #3
"John Beschler" <Jo**********@discussions.microsoft.comwrote in message
news:17**********************************@microsof t.com...
John,

Thanks for the reply. I had actually considered using a property to select
which URL; however, I was unable to figure out a way to create the
reference.
Could you point me to some examples of how to do this?
Just use Add Web Reference as normal. This creates a proxy class that
derives from the HttpWebClientProtocol class. That is the class with the
Url property. So:

public class MyComponent : IDisposible
{
private localhost.Server _proxyInstance;
private string _url;

public string Url
{
get {return _url;} set {_url = value;}
}

public void MethodThatCallsWS()
{
if (_proxyInstance == null)
{
_proxyInstance = new localhost.Server();
}

_proxyInstance.Url = Url;

_proxyInstance.WebMethod();
}

void IDisposible.Dispose()
{
if (_proxyInstance != null)
{
((IDisposible) _proxyInstance).Dispose();
}
}
}
--
John Saunders [MVP]

Aug 28 '07 #4
That worked!!!!!
Thanks so much for the help!!!1

John
"John Saunders [MVP]" wrote:
"John Beschler" <Jo**********@discussions.microsoft.comwrote in message
news:17**********************************@microsof t.com...
John,

Thanks for the reply. I had actually considered using a property to select
which URL; however, I was unable to figure out a way to create the
reference.
Could you point me to some examples of how to do this?

Just use Add Web Reference as normal. This creates a proxy class that
derives from the HttpWebClientProtocol class. That is the class with the
Url property. So:

public class MyComponent : IDisposible
{
private localhost.Server _proxyInstance;
private string _url;

public string Url
{
get {return _url;} set {_url = value;}
}

public void MethodThatCallsWS()
{
if (_proxyInstance == null)
{
_proxyInstance = new localhost.Server();
}

_proxyInstance.Url = Url;

_proxyInstance.WebMethod();
}

void IDisposible.Dispose()
{
if (_proxyInstance != null)
{
((IDisposible) _proxyInstance).Dispose();
}
}
}
--
John Saunders [MVP]

Aug 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: mlimber | last post by:
This is a repost (with slight modifications) from comp.lang.c++.moderated in an effort to get some response. I am using Loki's Factory as presented in _Modern C++ Design_ for message passing in...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
2
by: Gregory Gadow | last post by:
I am writing a service using VB.NET 2.0. One of the first steps is to retrieve some settings from the registry; I need the activation of the service to halt if these settings are not found. ...
4
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
0
by: JohnP | last post by:
Hi all Does anyone know the best way to get feedback from a Windows Service? I have written a Windows service which uses a class library (a DLL) which has a timer which does some operations...
20
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
I was executing the steps given in http://suppor.microsoft.com/kb/308359 for testing a sample web service application. However, the following line gives a compilation error: localhost.Service1...
1
by: =?Utf-8?B?YQ==?= | last post by:
Does anyone know if there is a way to force the studio debugging to break at any line of code when any string is initialized with a certain value? In this case I inherited a badly written app and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.