Natasha Thapa
Natasha Thapa

Reputation: 969

WCF Hostname in wsdl and svc page

when i deploy my WCF service, the wsdl shows up with import http://hostname/servicename/xsd how can i make it have IP address instead of the host name. same with the wsdl url that is listed when you browse to svc file.

Upvotes: 0

Views: 1500

Answers (3)

IdoFlatow
IdoFlatow

Reputation: 1438

Some things you can do:
1. Change the address of the endpoint to use ip instead of host name - this will work when hosting outside of iis.
2. If the purpose of this change is to allow users to add a reference by using the server's IP, you can add the useRequestHeadersForMetadataAddress service behavior that will allow the wsdl to be changed according to the address the client uses to get the WSDL

Upvotes: 1

Mike
Mike

Reputation: 339

On IIS you could do the following. Open CMD, type:

cscript.exe %systemdrive%\inetpub\adminscripts\adsutil.vbs get w3svc/<Website-ID>/ServerBindings

to view the current binding

Open CMD, type:

cscript.exe %systemdrive%\inetpub\adminscripts\adsutil.vbs set w3svc/<Website-ID>/ServerBindings ":<PORT><IP>"

This will result in having IP:PORT in WDSL.

You have to lookup <Website-ID> before in IIS Manager ("Sites").

Upvotes: 1

Davide Piras
Davide Piras

Reputation: 44605

Look at the service reference properties in Visual Studio to change url from hostname to Ip address.

In general you should not have hard-coded values in there, no ip addresses and no names, you can put these settings in the web.config or other config file or in the database so you don't have to change too many things when an IP address or host name changes or you simply deploy somewhere else fo testing, production and so on...

Upvotes: 0

Related Questions