--------------------
| Hi there,
|
| I would like to dynamically choose the URL of a web reference in an
Asp.Net
| application.
| Usually, we set a attribute in the web.config:
|
| <applicationSettings>
| <MyProject.Properties.Settings>
| <setting name="MyService" serializeAs="String">
| <value>
http://server:90//service1.asmx</value>
| </setting>
| </MyProject.Properties.Settings>
| </applicationSettings>
|
| and the auto-generated file "Reference.cs" contains these lines:
|
| public MyService() {
| this.Url =
| global::MyProject.Properties.Settings.Default.MyService;
| ...}
|
| How can I bypass the behaviour to write my own MyService constructor ?
|
| Best regards
|
|
|
|
Hello Oriane,
Based on my understanding, you want to specify the webservice url
dynamically in your own class or event. If I have misunderstood you, please
feel free to let me know.
As far as I know, you can define the property "url" of the webservice proxy
instance.
For example, we have two web service references: test1 and test2(both have
the web method "HelloWorld").
1. Firstly, We should define a instance for one of them.
2. You can redefine Url for it.
3. It will execute "HelloWorld" of test2.asmx.
lh.test1 ws = new lh.test1();
ws.Url = "
http://localhost:11587/WebService/test2.asmx";
ws.HelloWorld();// In this scenario, I assume that HelloWorld is
the web method name that exists in both test1.asmx and test2.asmx. If the
name of the web method(the member of test2) you call doesn't exist in test1
instance, the compiler will throw the error becuase HelloWorld is not the
member of test1. Then we have to invoke the web method dynamically by using
HttpWebRequest.
Regarding on the Webservice proxy with dynamic URL behavior's url string
stroage question, I suggest the URL string for dynamic behavior webservice
proxy should be in application config file (app.config or web.config....).
Sincerely,
Vince Xu
Microsoft Online Support
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½£½