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

Dynamic Web Service Reference

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

--
-Demetri
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

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

Replies have been disabled for this discussion.