开发者

WCF Hostname in wsdl and svc page

开发者 https://www.devze.com 2023-03-26 18:19 出处:网络
when i deploy my WCF service, the wsdl shows up with 开发者_高级运维import http://hostname/servicename/xsd

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.


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


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").


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号