views:

2122

answers:

7

Hi,

My WCF seems to be pulling the computer-name instead of the domain name.

When I view the MyService.svc?wsdl 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

A: 

See if this post can help.

Darin Dimitrov
what a hack. Is this a known bug because I can't see how shared hosters handle this!
Blankman
+2  A: 

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>
  ...
voidmain
+1  A: 

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

blowdart
A: 

This post solved it for me. I needed to associate my domain name with my IP address and website in IIS.

http://www.codemeit.com/wcf/wcf-wsdl-xsdimport-schemalocations-link-to-local-machine-name-not-domain-name-while-hosted-in-iis.html

Shane
+1  A: 

I have added solutions here, http://knowledgebaseworld.blogspot.com/2010/06/domain-name-replaced-with-machine-name.html. it should work for you all as its working fine with me on local, staging and production without doing binding on iis

IBhadelia
A: 

None of these solutions were helpful to me. I was able to solve this with a very simple custom Service Factory.

Installing a WCF Service on a Shared Hosting Site, Revisited

Chris Marisic
A: 

Have you tried setting the host header in IIS?

Junto