By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,900 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,900 IT Pros & Developers. It's quick & easy.

C# and Web References

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.