473,839 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change WCF client endpoint address

Hi,

How could I change a WCF client endpoint address programatically ? The client
is generated by Visual Studio. The purpose of doing this is to use different
service address under different configuration.

Thanks.

Daniel
Aug 22 '07 #1
4 56931
On Aug 22, 3:50 am, Daniel <daniel.s...@ne wsgroup.nospamw rote:
Hi,

How could I change a WCF client endpoint address programatically ? The client
is generated by Visual Studio. The purpose of doing this is to use different
service address under different configuration.

Thanks.

Daniel
Once you have an instance of the client side proxy 'ws', you can
change the URL via code like...

ws.Endpoint.Add ress = new
System.ServiceM odel.EndpointAd dress( newurl )

As a side notes, in my case I also have dynamic option to use HTTP or
HTTPS where I also have to specify which binding to use, so I have the
following code..

ws.Endpoint.Bin ding = new System.ServiceM odel.BasicHttpB inding
( bHttps ? "httpsBindi ng" : "httpBindin g" )

where the two values refer to binding names in the web.config file

Ron

Aug 22 '07 #2
Thanks Ron. I have tried this approach but it seems to have no effect. The
address still remains the same. Is there anything else I need to do to make
this work?

Daniel
"ro************ *@yahoo.com" wrote:
On Aug 22, 3:50 am, Daniel <daniel.s...@ne wsgroup.nospamw rote:
Hi,

How could I change a WCF client endpoint address programatically ? The client
is generated by Visual Studio. The purpose of doing this is to use different
service address under different configuration.

Thanks.

Daniel

Once you have an instance of the client side proxy 'ws', you can
change the URL via code like...

ws.Endpoint.Add ress = new
System.ServiceM odel.EndpointAd dress( newurl )

As a side notes, in my case I also have dynamic option to use HTTP or
HTTPS where I also have to specify which binding to use, so I have the
following code..

ws.Endpoint.Bin ding = new System.ServiceM odel.BasicHttpB inding
( bHttps ? "httpsBindi ng" : "httpBindin g" )

where the two values refer to binding names in the web.config file

Ron

Aug 23 '07 #3
Hi Daniel,

If what you want to do is just change the client WCF proxy's endpoint
address(in case you need to redirect to new server programmtically ?), you
can use the following options:
1. You can pass a new Endpoint address instance(with the new url) in your
WCF client proxy's constructor, e.g.

<<<<<<<<<<<<<<< <<<<<
static void RunProxy()
{
HelloWorld.Hell oWorldClient hello =
new
HelloWorld.Hell oWorldClient("B asicHttpBinding _IHelloWorld",
new
EndpointAddress ("http://localhost:8888/BasicHost/HelloWorld"));

string ret = hello.SayHello( "WCF");

Console.WriteLi ne(ret);
}
>>>>>>>>>>>>>>> >

2. Or you can also create the WCF proxy first and change the
endpointAddress member after that. e.g.
>>>>>>>>>>>>>>> >
HelloWorld.Hell oWorldClient client = new
WCFHelloWorldCl ient.HelloWorld .HelloWorldClie nt();

//change the endpointAddress here
client.Endpoint .Address = new
EndpointAddress ("http://localhost:8899/BasicHost/HelloWorld");

Console.WriteLi ne(client.SayHe llo("steven"));

<<<<<<<<<<<<< <

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 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 or complex
project analysis and dump analysis issues. 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/subscripti...t/default.aspx.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 23 '07 #4
Thanks Steven, the first approach works.

Daniel
"Steven Cheng[MSFT]" wrote:
Hi Daniel,

If what you want to do is just change the client WCF proxy's endpoint
address(in case you need to redirect to new server programmtically ?), you
can use the following options:
1. You can pass a new Endpoint address instance(with the new url) in your
WCF client proxy's constructor, e.g.

<<<<<<<<<<<<<<< <<<<<
static void RunProxy()
{
HelloWorld.Hell oWorldClient hello =
new
HelloWorld.Hell oWorldClient("B asicHttpBinding _IHelloWorld",
new
EndpointAddress ("http://localhost:8888/BasicHost/HelloWorld"));

string ret = hello.SayHello( "WCF");

Console.WriteLi ne(ret);
}
>>>>>>>>>>>>> >>


2. Or you can also create the WCF proxy first and change the
endpointAddress member after that. e.g.
>>>>>>>>>>>>> >>

HelloWorld.Hell oWorldClient client = new
WCFHelloWorldCl ient.HelloWorld .HelloWorldClie nt();

//change the endpointAddress here
client.Endpoint .Address = new
EndpointAddress ("http://localhost:8899/BasicHost/HelloWorld");

Console.WriteLi ne(client.SayHe llo("steven"));

<<<<<<<<<<<<< <

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 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 or complex
project analysis and dump analysis issues. 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/subscripti...t/default.aspx.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights
Aug 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2210
by: Gleb | last post by:
Is it possible to know client IP address in Web Service method using Apache SOAP on Tomcat? Thank you.
8
448
by: Homer | last post by:
How can I obtain the client IP address or machine name from within an asp.net application? I want to use this information to determine where to redirect a web page. Many thanks Homer
7
21325
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of someone (client) that visits a web site through an anonymous proxy if this person ONLY has JavaScript enabled in their browser? This is NOT a question about PHP, perl, VBScript, Java(.class), or ActiveX. Let us _only_ deal with JavaScript for...
0
1212
by: tracy | last post by:
CHANGE OF EMAIL ADDRESS NOTIFICATION Dear Clients, Suppliers & Friends, Effective August 1st 2005, my new email address will be tracytaw@swotdesigngroup.com. During this transition period, I'll still be receiving mails from my old account. Thanks & Regards,
19
2605
by: chee.k.cheng | last post by:
Hi, I'm wondering if it is possible to change the starting address of a structure element. For example, I have the following structure: struct demo { char digit; char alpha; } an;
13
28790
by: Sandeep Singh | last post by:
I am making socket client application in C# how can i get ip address of client who has connected to server
1
3129
by: Tony | last post by:
I would really appreciate it if anyone has any thoughts on this one - it's driving us mad. We have a web site which is using ASP.NET 1.1 and which is load balanced across two web servers with IP affinity. It generally works very well. We have set enableViewStateMac="false" and to be sure we have set the same machine key on each of the web servers (i.e. <system.web><machinekey....>) We have a particular scenario which is causing us big...
0
1648
by: Jeremy Monnet | last post by:
Hello, I've started python a few weeks ago, and to now everything went fine with my cookbook and a learning book. Now, I've tried the SimpleXMLRPCServer, and it worked OK untill I tried to get the client IP address. I have searched a long time the Internet but couldn't find a _simple_ solution :-) #Code
10
16825
by: skyy | last post by:
Hi.. I am working on a CGI script to enable client to obtain the server ip address and then change to the IP address it prefer. The server IP address can be obtain from the environment variable SERVER_ADDR I am trying to change the IP address of the server with the following script: #!/usr/bin/perl -w
0
10585
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10647
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10292
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7828
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7017
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3132
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.