Blankman
Blankman

Reputation: 267000

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

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

Upvotes: 32

Views: 29569

Answers (13)

Pedro Dias
Pedro Dias

Reputation: 81

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>

Upvotes: 8

subho
subho

Reputation: 59

Thanks to Kanasz Robert. Steps that solved my problem - 1.Produce the wsdl in the browser and save to file (by hitting .svc?wsdl from browser) save as .wsdl

  1. Produce the xsd files by hitting url from wsdl (xsd=xsd0, etc), and save to file from browser, save as .wsdl

  2. replace all machine name references from wsdl with domain name (or ip address) and change xsd references and save AND replace all machine name references from xsd files with domain name (or ip address) make sure to name xsd file with .xsd extension (ie, name0.xsd, name1.xsd, name2.xsd)

  3. copy wsdl and xsd file(s) to virtual directory add to your web.config following lines:

<behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://IPorDomainName/MyServices/FileTransferService.wsdl"  />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

Upvotes: 0

ABN
ABN

Reputation: 21

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.

Upvotes: 2

User0106
User0106

Reputation: 537

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

<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

Upvotes: 4

David Masters
David Masters

Reputation: 8295

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

Upvotes: 1

Khurram Tanwir
Khurram Tanwir

Reputation: 11

Although its an old posting, here is an answer. Under Service Behaviour --> ServiceMetaData add service url.

Please note if you do not add myService, it will throw another error.

Upvotes: 1

nick_alot
nick_alot

Reputation: 3012

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>

Upvotes: 27

Rebecca
Rebecca

Reputation: 14402

Have you tried setting the host header in IIS?

Upvotes: 1

Chris Marisic
Chris Marisic

Reputation: 33098

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

Upvotes: 1

IBhadelia
IBhadelia

Reputation: 291

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

Upvotes: 1

Shane
Shane

Reputation: 1216

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

Upvotes: 0

blowdart
blowdart

Reputation: 56500

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

Upvotes: 9

Aleksander Belov
Aleksander Belov

Reputation: 616

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

Upvotes: 3

Related Questions