We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


How to edit the endpoint address in reference.cs file?

esko_user asked
Medium Priority
Last Modified: 2013-12-17
Hello i have referred an web service in my client application and i want to change/override the endpoint address which is referenced. I was trying to specify the endpoint address in my reference.cs class but still this is not working. can anyone help me on this

orginal reference.cs
public partial class HelloWorldClient : System.ServiceModel.ClientBase<sampleweb.ServiceReference1.HelloWorld>, sampleweb.ServiceReference1.HelloWorld {
        public HelloWorldClient() {
        public HelloWorldClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        public HelloWorldClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        public HelloWorldClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        public HelloWorldClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
I edited the web service address for this class as shown below,
public HelloWorldClient()
     //   new ServiceReference1.HelloWorldClient("HelloWorldSoapPort", "http://localhost:8080/ShowServiceA");
        public HelloWorldClient(string HelloWorldSoapPort) :
        public HelloWorldClient(string HelloWorldSoapPort, string remoteAddress) :
            base(HelloWorldSoapPort, "http://localhost:8080/ShowServiceA")
        public HelloWorldClient(string HelloWorldSoapPort, System.ServiceModel.EndpointAddress remoteAddress) :
            base(HelloWorldSoapPort, "http://localhost:8080/ShowServiceA")
        public HelloWorldClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
            base("HelloWorldSoapBinding", "http://localhost:8080/ShowServiceA")

Open in new window

Watch Question

You shouldn't do that....
Basically the generated proxy (reference.cs) should not be modified. The address is basically read from app.config file and is usually set to localhost - where you can change it if you want to.
But if you want to modify it on the fly, programatically, the best choice is to modify it via the exposed properties of System.Web.Services.Protocols.SoapHttpClientProtocol (or whatever is the base class for your service in reference.cs).

I mean you can do, when you instantiate the service:

MyService serviceProxy = new MyService();
serviceProxy.Url = "http://... the new endpoint you want ...     ";
.... call methods

and that will direct your calls to the new endpoint. Of course you must have at that endpoint the service and the types and the methods with the same signature.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.