473,405 Members | 2,185 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,405 software developers and data experts.

C# and Web References

Hi,

We have a web service that has mutliple levels; one for test, one for
QA and the other for production. With that, we also have one C#
component that accesses the web service depending on the level. What I
want to do is be able to compile the C# component once and have a
reference to all web services. There is code in the C# component to
indicate which web service to reference based on a registry setting.
However, the problem that I am having is that it fails to compile
because there are multiple instances to the same objects in the
different web references.

So, my question is: If I have the same web service setup in three
different locations knowing one is for testing, another for QA and
another for production how can I reference the ONE web reference I
need to use without having to compile it every time it moves to each
level?

Currently I have using statements setup to access each web reference.

Example Below:

using QAWebService;
using TestWebService;
using ProdWebService;

namespace Some.Namespace.Here
{
public class SomeClass
{
//
// Connect to the appropriate web service
//
switch (wsType)
{
case "TEST":
TestWebService webService = new TestWebService();
break;
case "QA":
QAWebService webService = new QAWebService();
break;
case "Prod":
ProdWebService webService = new ProdWebService();
break;
}

//
// Instantiate/Initialize a single request shared between
// each web service.
//
SomeRequest someReq = new SomeRequest();

someReq.Version = 1;
}
}

It fails compiling on the creation of "SomeRequest" because it is
ambiguous. Can anyone help?

Thanks,
Holly
Nov 15 '05 #1
1 8033
Instead of setting a web reference, use wsdl.exe to create a proxy class
(this is basically what setting a web reference is doing for you). Then you
can modify the proxy class to decide at runtime which URL to hit based on
your registry key.

Or, look at the SoapHttpClientProtocol's Url property (the proxy class wsdl
generates derives from this) to set the Url at runtime.

Note that this assumes you have the same namespace for all three services
(that is, they are the same service on three different machines).

"Holly" <hm****@earthlink.net> wrote in message
news:81*************************@posting.google.co m...
Hi,

We have a web service that has mutliple levels; one for test, one for
QA and the other for production. With that, we also have one C#
component that accesses the web service depending on the level. What I
want to do is be able to compile the C# component once and have a
reference to all web services. There is code in the C# component to
indicate which web service to reference based on a registry setting.
However, the problem that I am having is that it fails to compile
because there are multiple instances to the same objects in the
different web references.

So, my question is: If I have the same web service setup in three
different locations knowing one is for testing, another for QA and
another for production how can I reference the ONE web reference I
need to use without having to compile it every time it moves to each
level?

Currently I have using statements setup to access each web reference.

Example Below:

using QAWebService;
using TestWebService;
using ProdWebService;

namespace Some.Namespace.Here
{
public class SomeClass
{
//
// Connect to the appropriate web service
//
switch (wsType)
{
case "TEST":
TestWebService webService = new TestWebService();
break;
case "QA":
QAWebService webService = new QAWebService();
break;
case "Prod":
ProdWebService webService = new ProdWebService();
break;
}

//
// Instantiate/Initialize a single request shared between
// each web service.
//
SomeRequest someReq = new SomeRequest();

someReq.Version = 1;
}
}

It fails compiling on the creation of "SomeRequest" because it is
ambiguous. Can anyone help?

Thanks,
Holly

Nov 15 '05 #2

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

Similar topics

17
by: Tom | last post by:
The motivation for references seems clear: stop people from using nasty pointers when all they really want is a reference to an object. But C++ references are so inadequate that I'm still using...
22
by: xmp333 | last post by:
Hi All, I am trying to hide my JavaScript source. The method I chose was to keep all the important source in a password protected folder, and then use a SRC="folder/script.js" to include it...
33
by: JKop | last post by:
I understand variables/objects and pointer variables perfectly: int X = 5; int* pX = &X; *pX = 4; int** ppX = &pX:
2
by: S. van Beek | last post by:
Dear reader, For removing a reference in the VBA reference form I receive from Doug Steele the following code: ........... References.Remove refCurr
11
by: codebloatation | last post by:
I know how to use references but i DO not get WHY they exist other than to add to the language. Are they actually needed for anything?
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
30
by: jeremygetsmail | last post by:
I've got an adp (Metrix.adp) with a reference to another adp (InteractSQL.adp). InteractSQL sits on a server, and is refered to by all of the clients (Metrix), which sit on the client machines...
3
by: DonJefe | last post by:
Does anyone have experience using project->project references in large solutions? What are the plus/minuses that you have found? Currently, we are using the binary assembly references for our...
9
by: igor.kulkin | last post by:
References is a relatively basic feature of C++ language. It might be a good thing to think of references as aliases to the variables. However it's good to think of references this way when you...
3
by: CenturionX | last post by:
Hello everybody: I'd like to know what references in my vba code are used or not. I work in a code made by another person previously, i founded to many references and i believe that someones...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.