WCF not using computer name instead of domain name when viewing MyService.svc?wsdl

后端 未结 13 1286
迷失自我
迷失自我 2020-12-13 02:31

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.

Wh

相关标签:
13条回答
  • 2020-12-13 02:39

    I had this very issue with my production server. I have found various articles on the multiple host headers with IIS and WCF issue, but if you are using SSL, you cannot add a host header to the website identities within the IIS UI, you can only add them to normal HTTP identities:

    enter image description here

    However you can add SSL host headers via a command prompt script, and this solved the issue for me:

    cscript.exe adsutil.vbs set /w3svc/<site identifier>/SecureBindings ":443:<host header>"
    

    For more information on this see this link: http://blumenthalit.net/blog/Lists/Posts/Post.aspx?ID=14

    0 讨论(0)
  • 2020-12-13 02:40

    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

    0 讨论(0)
  • 2020-12-13 02:41

    just adding <useRequestHeadersForMetadataAddress></useRequestHeadersForMetadataAddress> to the solved my issue. It seems that WCF 4.0 takes care of the Headers by adding this I was using SSL for accessing the WCF Service.

    0 讨论(0)
  • 2020-12-13 02:51

    To fix this problem Configure the httpGetEnabled attribute and httpsGetEnabled attribute in web.config file

    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
    
    0 讨论(0)
  • 2020-12-13 02:51

    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>
      ...
    
    0 讨论(0)
  • 2020-12-13 02:51

    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

    0 讨论(0)
提交回复
热议问题