473,768 Members | 6,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Web Service Reference

Is it possible to add a web service reference during runtime? If so, how?

--
-Demetri
Nov 18 '05 #1
5 3083
Hi Demetri:

I'd start by looking at the ServiceDescript ionReflector and
ServiceDescript ionImporter classes from
System.Web.Serv ices.Descriptio n. From here you could essentially write
your own WSDL.exe tool that compiles proxies in memory.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 1 Nov 2004 09:23:12 -0800, "Demetri"
<De*****@discus sions.microsoft .com> wrote:
Is it possible to add a web service reference during runtime? If so, how?


Nov 18 '05 #2
no. a web service reference builds a proxy stub for the webservice. it
creates a class with a method for each web service method, with a matching
parameter list. the method call the web service and returns the results. at
runtime you can change the URL if you want.

if you want to dynamically call a web service at runtime, your fetch its
WDSL, and use the .net libraries to parse it, and make the call. you could
build the proxy at runtime using the wsdl.exe tool to generate the source
code, then compile and load the dll. after loading you could use reflection
to make the calls.

-- bruce (sqlwork.com)


"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
Is it possible to add a web service reference during runtime? If so, how?

--
-Demetri

Nov 18 '05 #3
Basically, what I want is to have the development version, testing version,
and production versions of the web application to consume the appropriate web
service version (dev, test, prod - respectively). What is the best way to
accomplish this without having to create a separate project for each
environment so it can have its own web references?

Thanks
-Demetri

"bruce barker" wrote:
no. a web service reference builds a proxy stub for the webservice. it
creates a class with a method for each web service method, with a matching
parameter list. the method call the web service and returns the results. at
runtime you can change the URL if you want.

if you want to dynamically call a web service at runtime, your fetch its
WDSL, and use the .net libraries to parse it, and make the call. you could
build the proxy at runtime using the wsdl.exe tool to generate the source
code, then compile and load the dll. after loading you could use reflection
to make the calls.

-- bruce (sqlwork.com)


"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
Is it possible to add a web service reference during runtime? If so, how?

--
-Demetri


Nov 18 '05 #4
Hi Demetri:

It sounds as if you need to point the proxy classes at the correct
URL. This would be an easier problem than we first thought. Set the
UrlBehavior property to Dynamic in the properties window and the IDE
will add a section to the application's config file with the URL for
the service. I.e:

<configuratio n>
<appSettings><a dd key="SomeProjec t.localhost.Ser vice1"
value="http://localhost/SomeWebService/Service1.asmx"/>
</appSettings>
</configuration>

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 1 Nov 2004 12:01:03 -0800, "Demetri"
<De*****@discus sions.microsoft .com> wrote:
Basically, what I want is to have the development version, testing version,
and production versions of the web application to consume the appropriate web
service version (dev, test, prod - respectively). What is the best way to
accomplish this without having to create a separate project for each
environment so it can have its own web references?

Thanks
-Demetri

"bruce barker" wrote:
no. a web service reference builds a proxy stub for the webservice. it
creates a class with a method for each web service method, with a matching
parameter list. the method call the web service and returns the results. at
runtime you can change the URL if you want.

if you want to dynamically call a web service at runtime, your fetch its
WDSL, and use the .net libraries to parse it, and make the call. you could
build the proxy at runtime using the wsdl.exe tool to generate the source
code, then compile and load the dll. after loading you could use reflection
to make the calls.

-- bruce (sqlwork.com)


"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
> Is it possible to add a web service reference during runtime? If so, how?
>
> --
> -Demetri



Nov 18 '05 #5
Great!! That solves my problem.

Thanks!!

"Scott Allen" wrote:
Hi Demetri:

It sounds as if you need to point the proxy classes at the correct
URL. This would be an easier problem than we first thought. Set the
UrlBehavior property to Dynamic in the properties window and the IDE
will add a section to the application's config file with the URL for
the service. I.e:

<configuratio n>
<appSettings><a dd key="SomeProjec t.localhost.Ser vice1"
value="http://localhost/SomeWebService/Service1.asmx"/>
</appSettings>
</configuration>

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 1 Nov 2004 12:01:03 -0800, "Demetri"
<De*****@discus sions.microsoft .com> wrote:
Basically, what I want is to have the development version, testing version,
and production versions of the web application to consume the appropriate web
service version (dev, test, prod - respectively). What is the best way to
accomplish this without having to create a separate project for each
environment so it can have its own web references?

Thanks
-Demetri

"bruce barker" wrote:
no. a web service reference builds a proxy stub for the webservice. it
creates a class with a method for each web service method, with a matching
parameter list. the method call the web service and returns the results. at
runtime you can change the URL if you want.

if you want to dynamically call a web service at runtime, your fetch its
WDSL, and use the .net libraries to parse it, and make the call. you could
build the proxy at runtime using the wsdl.exe tool to generate the source
code, then compile and load the dll. after loading you could use reflection
to make the calls.

-- bruce (sqlwork.com)


"Demetri" <De*****@discus sions.microsoft .com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
> Is it possible to add a web service reference during runtime? If so, how?
>
> --
> -Demetri


Nov 18 '05 #6

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

Similar topics

8
2541
by: Eyeawanda Pondicherry | last post by:
I have put some code together that creates an enum dynamically from some database values. The enum can be read perfectly by an application that references the dynamically generated dll. If I /emit/ a new version of the assembly, and start the application again, the new values will appear for the enum. However, suppose I want the application to remain in a running state.
15
2065
by: Nak | last post by:
Hi there, Is it possible to load a web service dynamically? i.e. If the web service were to exist on a system with a non static IP address, an application could download a "locator" file that contained details of it's whereabouts, I have been looking at the "Discovery.DynamicDiscoveryDocument" class but I think think this is what I am looking for is it? Thanks in advance. Nick.
0
3522
by: blekros | last post by:
All, I have a web service client written in VB.NET. It is a class library assembly (.dll file). I made a web reference to a web service and set it to be dynamic, so it puts the URL of the web-reference in the application configuration file (app.config) However, at runtime, the code in the DLL thinks that the config file is the config file of the .exe calling it. It obviously does not contain my web reference. Here is my proxy...
4
4172
by: Maziar Aflatoun | last post by:
Hi, Is there a way to connect to a Web Service dynamically at runtime (Web Reference URL)? I have always used Visual Studio to create a Web Reference and then used it in my code. However, that always requires the URL to the Web Service to be the same on the staging site and the production site. Now I have two instances of the same application running (Staging site and Production) and want to store the URL in a file instead. Is there a...
7
22496
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We added an entry to the executable's .exe.config file to specify the URL, and under the 1.1 framework this worked well. Unfortunately, this is not working under the 2.0 framework. I see in the Reference.cs file under the web service reference the...
5
6218
by: Kimba | last post by:
Hi. Using VStudio I have developed a WebService which I placed onto several servers. However my application can only access one on server. During runtime, I tried to change the URL of the webreference to the other server but that does not work -- the webreference still thinks it is the old one and errors out. I need to be able to dynamically switch from one server to the other, but
2
2540
by: James | last post by:
Hello, I have an existing MFC C++ project which I need to add the ability of sending WSDL calls out to a web service. When this project is deployed the web service URL will always change depending on the user's local setup. I can use the "Add a Web Reference" wizard to do this, however when the project is in C++ the option to set the URL Behaviour to Dynamic is not in the property list. I noticed if I create a C# project however,...
2
1306
by: HockeyFan | last post by:
I have a web service that has been working, but I recently changed it so that the reference would be dynamic. Locally, within Visual Studio, it works fine. However, once deployed, the dll I use to access it has trouble. I get a null reference exception and figure it's because of the change to dynamic url. I noticed in the discovery file and the wsdl file that the old reference (to localhost) is still there. What do they need to be in...
1
2834
by: =?Utf-8?B?Sm9yZGFuIFou?= | last post by:
We did a same code base test between 1.1 and 3.5. In 1.1, when your .NET application reference a library with web reference (dynamic), you can always easily overwrite the default URL by specifying a different URL in your app config file or web config file. Now, in 3.5, I find that this no longer works. No matter what URL you specify in app config, it still point to default URL, which seems to be a serious bug to us.
0
9407
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10017
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9961
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5283
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.