473,395 Members | 1,631 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,395 software developers and data experts.

How to reference a reference type?

Hi

I have two web services running in different locations. I would like to
write some code to automatically fail over to the secondary if the
primary fails.

Rather than duplicating all my code I was hoping there was a simple way
to reference different type in a generic way. Is is possible to enter a
type as a string and convert it somehow?

My web services sit under the App_WebReferences folder. One is called
WebService1 and the other is called WebService2. Both have a service
called security with a number of methods. Both are currently referenced
using the following syntax;

WebService1.Security wsSec = new WebService1.Security();

This is wrapped in an if statement that uses an integer to determine
which one to use (I have already checked that the web services are
running as Session Start).

I want to be able to create a generic type which can reference either
web service. I don't want to have to wrap every piece of code that
references the web service in an if statement. This is made especially
difficult, as some of the web service methods use structs as well.

I have looked at delegates, but they only seem to work for methods.

Any help would be appreciated.

Thanks

Jared

Oct 10 '06 #1
3 1390
Can't you just have a single reference, and update the Url property at
runtime when it falls over?

Marc
Oct 10 '06 #2
Sometimes the simplest methods are the most effective...

Thanks

Jared

Oct 10 '06 #3
>From the description of your problem, it sounds like the Singleton
pattern would help you out here. Make an additional method on the
singleton that would "switch" the instance returned from the singleton.
This way you have a central access point of your webserver instance.

Heres the singleton description :
http://www.dofactory.com/Patterns/PatternSingleton.aspx

Would that work?

Sean

Jared wrote:
Hi

I have two web services running in different locations. I would like to
write some code to automatically fail over to the secondary if the
primary fails.

Rather than duplicating all my code I was hoping there was a simple way
to reference different type in a generic way. Is is possible to enter a
type as a string and convert it somehow?

My web services sit under the App_WebReferences folder. One is called
WebService1 and the other is called WebService2. Both have a service
called security with a number of methods. Both are currently referenced
using the following syntax;

WebService1.Security wsSec = new WebService1.Security();

This is wrapped in an if statement that uses an integer to determine
which one to use (I have already checked that the web services are
running as Session Start).

I want to be able to create a generic type which can reference either
web service. I don't want to have to wrap every piece of code that
references the web service in an if statement. This is made especially
difficult, as some of the web service methods use structs as well.

I have looked at delegates, but they only seem to work for methods.

Any help would be appreciated.

Thanks

Jared
Oct 10 '06 #4

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

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
4
by: z_learning_tester | last post by:
I'm reading the MS press C# book and there seems to be a contradiction. Please tell me which one is correct, 1 or 2. Thanks! Jeff 1. First it gives the code below saying that it prints 0 then...
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
4
by: Edward Diener | last post by:
I have a class Y in assembly B which is derived from a class Z in assembly C. So I correctly add a reference to assembly C in assembly B, build assembly B and everything builds fine. Now I create...
5
by: Mike Logan | last post by:
I used WSDL.exe to generate a client side web proxy for a web service, called the web service, got the results but an array returned by the web service is not in the results. However if I use...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
9
by: Edward Diener | last post by:
Can one use 'ref' ( or 'out' ) on a reference type to create a reference to a reference in C#. I know one can use it on a value type to create a reference to that value.
27
by: Terry | last post by:
I am getting the following warning for the below function. I understand what it means but how do I handle a null reference? Then how do I pass the resulting value? Regards Warning 1...
1
by: az.anonymous | last post by:
Im starting to learn C#, and I made a simple stack class. Inside the stack class I had the following: class StackElement { object info; StackElement below; } Everything works fine cause...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.