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.
"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.SoapRpcMethodAttribute("
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.SoapRpcMethodAttribute(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