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

Change web proxy method attribute at run time

P: n/a
Here is what I have and what I would like to do:
I am building a web client application.
I add a web reference to some web service server to my project so that
now I can call the web service.
A proxy class is generated for me. This is nice. It works!
Now, the method that is generated in the proxy class has an attribute
preceding it that, among other things, contains the web address of the
web service and the particular method at that service to be called
like this:
System.Web.Services.Protocols.SoapRpcMethodAttribu te("http://some.machine/service/procedure",
, RequestNamespace="urn:querywsdl",
ResponseNamespace="urn:querywsdl")]

There will be more than one web service with the same interfaces
available for use. I will not know there names or locations at design
time. I would like to use this proxy class that I already have to
access the various different web services. Apparently the attribute
above controls where my call will go.

Is there some way to change this attribute value at run time? I tried
to create a variable and plug it in for the first value like this:

string MyParamater = "http://Set_this_machine_loc/at_run/time"
and then plug that in like this:
System.Web.Services.Protocols.SoapRpcMethodAttribu te(MyParamater,
, RequestNamespace="urn:querywsdl",
ResponseNamespace="urn:querywsdl")]

which causes a compile error "An attribute argument must be a constant
expression, typeof expression or array creation expression"
OK, so I cant plug in a variable. Is there some way to reuse this
proxy code while changing the destination service address and
procedure name at run time?
Would I have to write my own proxy class at some lower level?
Is there a way to intercept this message before it is sent to make the
change?

Any suggestions, links, how to are much needed and appreciated.

Thanks in advance
Jeff
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I may be misunderstanding all the meaning in your post, but the Service proxy
that you get from a WebReference contains a .Url property. This is all you
need to set prior to making a call to determine where the call is sent.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff User" wrote:
Here is what I have and what I would like to do:
I am building a web client application.
I add a web reference to some web service server to my project so that
now I can call the web service.
A proxy class is generated for me. This is nice. It works!
Now, the method that is generated in the proxy class has an attribute
preceding it that, among other things, contains the web address of the
web service and the particular method at that service to be called
like this:
System.Web.Services.Protocols.SoapRpcMethodAttribu te("http://some.machine/service/procedure",
, RequestNamespace="urn:querywsdl",
ResponseNamespace="urn:querywsdl")]

There will be more than one web service with the same interfaces
available for use. I will not know there names or locations at design
time. I would like to use this proxy class that I already have to
access the various different web services. Apparently the attribute
above controls where my call will go.

Is there some way to change this attribute value at run time? I tried
to create a variable and plug it in for the first value like this:

string MyParamater = "http://Set_this_machine_loc/at_run/time"
and then plug that in like this:
System.Web.Services.Protocols.SoapRpcMethodAttribu te(MyParamater,
, RequestNamespace="urn:querywsdl",
ResponseNamespace="urn:querywsdl")]

which causes a compile error "An attribute argument must be a constant
expression, typeof expression or array creation expression"
OK, so I cant plug in a variable. Is there some way to reuse this
proxy code while changing the destination service address and
procedure name at run time?
Would I have to write my own proxy class at some lower level?
Is there a way to intercept this message before it is sent to make the
change?

Any suggestions, links, how to are much needed and appreciated.

Thanks in advance
Jeff

Nov 17 '05 #2

P: n/a
Peter
OK, I see that and it appears to work!

Then what is the meaning/purpose of the url in the attribute:
System.Web.Services.Protocols.SoapRpcMethodAttribu te("http://some.machine/service/procedure",
, RequestNamespace="urn:querywsdl",
ResponseNamespace="urn:querywsdl")] ?

If I change "proxyClass.this.Url" to point to whatever service I want
to use, does the hard coded original service address (on the
attribute) affect anything? If not, can it be removed from that
attribute?

Thanks
Trying to learn all I can about this stuff
Jeff
On Sun, 23 Oct 2005 14:22:01 -0700, "Peter Bromberg [C# MVP]"
<pb*******@yahoo.nospammin.com> wrote:
I may be misunderstanding all the meaning in your post, but the Service proxy
that you get from a WebReference contains a .Url property. This is all you
need to set prior to making a call to determine where the call is sent.
Peter


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.