WCF not using computer name instead of domain name when viewing MyService.svc?wsdl
Solution 1
WCF 4.0 has solved this issue in some instances with a new config option that use Request Headers:
<behaviors>
<serviceBehaviors>
<behavior name="AutoVaultUploadBehavior">
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
Solution 2
For IIS7 you don't add it to web.config, but to the IIS configuration file.
First off edit the bindings for your web site so the HTTP protocol specifies a host name if you haven't already - this will ensure it gets the correct name under HTTP.
Navigate to C:\Windows\System32\inetsrv\config and open applicationHost.config
Look for the sites section. You will see something like the following
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:puck" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
<binding protocol="http" bindingInformation="*:80:puck.idunno.org" />
<binding protocol="http" bindingInformation="*:80:localhost" />
<binding protocol="https" bindingInformation="*:443:" />
</bindings>
</site>
....
</sites>
You can see that the bindings for the http protocol specify a host header, but https doesn't. When you're web browsing you can't use host headers over HTTPS, but WCF still uses it when generating the WSDL - if it can't find one it will fall back to the machine name.
So all you need to do is edit the HTTPS binding like so
<binding protocol="https" bindingInformation="*:443:puck" />
appending the correct FQDN to the end of the binding information. Reset IIS and WCF should get it right now.
The IIS6 solution has already been posted by darin
Solution 3
As stated in this link WCF is using the computer name instead of the IP address and cannot be resolved
It solved my problem, maybe because i have multiple web sites in the same host, and is very simple.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Solution 4
To fix this problem Configure the httpGetEnabled attribute and httpsGetEnabled attribute in web.config file
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
Solution 5
We're using WCFExtras to change the name of the host.
WCFExtras is a small open source library that will allow you to write the following to change the host name:
<behaviors>
<endpointBehaviors>
<behavior name="xxx">
<wsdlExtensions location="http://some-hostname-visible-from-outside/path-to-a-service/service.svc" singleFile="True" />
</behavior>
...
Comments
-
Blankman over 3 years
My WCF serice seems to be using the computer-name instead of the domain name. When I view the
MyService.svc?wsdl
link it is showing my computer name.Where do I add my domain name in the web.config? Endpoint address, baseaddress or identity?
Note: I am using SSL so it has to be
https://www.example.com/myservice.svc
-
Darin Dimitrov over 15 yearsSee if this post can help.
-
Blankman over 15 yearswhat a hack. Is this a known bug because I can't see how shared hosters handle this!
-
-
test almost 12 yearsThis works, but I run into a problem only the exact domain name I specify will work. For example if I do: *:443:domain.com Then only domain.com/Service.svc will work, if I do: *:443:www.domain.com Then only www.domain.com/Service.svc will work, but not both. How can I get both? (With https prefix)
-
a432511 about 11 yearsSame issue and this solution worked perfectly for me. Thanks!
-
Steve almost 11 yearsSimple, easy, exactly what is needed. Don't know why everyone else is suggesting all these other complicated solutions. This does exactly what the OP wants.
-
Rob Koch over 10 yearsThat was the cincher for me! Thanks @Haridharan
-
Piero Alberto about 9 yearsand for http? how to do it?