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

Dynamic Web Service Reference

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

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

I'd start by looking at the ServiceDescriptionReflector and
ServiceDescriptionImporter classes from
System.Web.Services.Description. 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*****@discussions.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*****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.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*****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.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:

<configuration>
<appSettings><add key="SomeProject.localhost.Service1"
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*****@discussions.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*****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.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:

<configuration>
<appSettings><add key="SomeProject.localhost.Service1"
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*****@discussions.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*****@discussions.microsoft.com> wrote in message
news:05**********************************@microsof t.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
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...
15
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...
0
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...
4
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...
7
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...
5
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...
2
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...
2
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...
1
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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,...

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.