.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > Update Service Reference redirects the service url from localhost to machinename
 

Update Service Reference redirects the service url from localhost to machinename

I have a simple WCF service that is consumed by a test client. The service is hosted in IIS. When I update the service reference, then the url in the app.config is changed from http://localhost/myservice.svc to http://mymachinename/myservice.svc . Of course this is not what I want, because when another developer picks up the code, (s)he first has to modify the config again.

How can I force not to use the machinename, but keep using localhost?
Ewald - Please remember to mark the replies as answers if they help.

Ewald Hofman
Blog: www.ewaldhofman.nl
Ewald Hofman - Avanade
Hi,

I am not very clear with your decription.

No matter how you want to manipulate your images staff by your wcf service, one thing we need to make sure that your service is hosted on your local machine which has the ip address is something like 127.0.0.1, 'localhost' is just a host name that mapping to this ip address. Nothing special, it can be change by editing the hosts file in C:\Windows\System32\drivers\etc.

But for your machinename which is identity for your machine, if your computer is in a company domain then your machine name will plus domain name, this is for network use. e.g another computer try to make a request to your wcf service on the same network domain, it has to know your machinename and domain name, this will be anylized by the DNS server to turn it into your real ip address on the network, then the another computer will be able to visite your machine.

However if you do need to expose your wcf service by localhost, you can spercifically define your service endpoint address like:

<endpoint address="http://localhost:81/try" binding="wsHttpBinding" contract="WcfService1.IService1">

Thanks
Binze
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Bin-ze Zhao
Hi Ewald,

you should specify the appropriate host header name for the IIS site hosting your service.

Regards,
Stipe-Ivan
Stipe-Ivan Latkovic
Hi,

I didn't reproduce your scenario, as I have hosted the wcf service in iis7 and consumed it in a console application(they both on same machine).

As the first time I added it through "add service reference" , the endpoint address in my client app.config is :
http://mymachinename/myservice.svc

Actually this is what it suppose to be, If this was consumed by another machineon the network and you still want to keep localhost as the machine dns, it will cause the client application to get information from its local host server and cause null exception.

Thanks
Binze
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Bin-ze Zhao
I worked in IIS 6.

We are working with images, which are replicates of each other. When you override the localhost with the machinename, then other developers are trying to connect to the same machine, but they have to use the endpoint on the localhost.

How can I achieve this?
Ewald - Please remember to mark the replies as answers if they help.

Ewald Hofman
Blog: www.ewaldhofman.nl
Ewald Hofman - Avanade
Hi,

I am not very clear with your decription.

No matter how you want to manipulate your images staff by your wcf service, one thing we need to make sure that your service is hosted on your local machine which has the ip address is something like 127.0.0.1, 'localhost' is just a host name that mapping to this ip address. Nothing special, it can be change by editing the hosts file in C:\Windows\System32\drivers\etc.

But for your machinename which is identity for your machine, if your computer is in a company domain then your machine name will plus domain name, this is for network use. e.g another computer try to make a request to your wcf service on the same network domain, it has to know your machinename and domain name, this will be anylized by the DNS server to turn it into your real ip address on the network, then the another computer will be able to visite your machine.

However if you do need to expose your wcf service by localhost, you can spercifically define your service endpoint address like:

<endpoint address="http://localhost:81/try" binding="wsHttpBinding" contract="WcfService1.IService1">

Thanks
Binze
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Bin-ze Zhao
ok. i get your point of machinename and localhost. i want that everyone that is working with the same solution uses the wcf service on their own machine. so when setting the endpoint to localhost i fulfill my request. so far so good. however when i now update the service reference the endpoint is changed to the machinename. i don't know whether the host header solves the problem. have to check that
Ewald - Please remember to mark the replies as answers if they help.

Ewald Hofman
Blog: www.ewaldhofman.nl
Ewald Hofman - Avanade

You can use google to search for other answers

Custom Search

More Threads

• HttpModule to remove .svc from urls throws 404 exception when use Wildcard for IIS 6
• Web service deserialize href's error
• .NET StockTrader Sample Application Technical Documentation
• What does exactly the ExtensionDataObject does ?
• Handling Fault exceptions in WCF
• How to consume WCF Service from C++
• WCF Service cant be referenced when using WPF, WCF, And LINQ , Pls Help
• WCF service unable to certain sizes of data?
• Returned Interfaces in ServiceContract not visible in WSDL
• Message size quota for incoming messages (65536) has been exceeded