21

I have a WCF service that is hosted in IIS 7.5. I have two servers, one for test and one for production.

The service works fine on test server, but on the production server I have the following error.

When I access the address http://..../service.svc I can see the default page that says:


You have created a service.

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe http://..../service.svc?wsdl

This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service.


But when I click the wsdl link, I cannot go to the wsdl page. It returns me to this default web page without any errors. I am suspecting a network/firewall authorization error but does anybody have an experience like this one?

All IIS settings are the same for test and production servers.

Thank you, Best Regards.

Maciej Pulikowski
  • 2,457
  • 3
  • 15
  • 34
Selcuk S.
  • 661
  • 2
  • 9
  • 19
  • do you have a mex endpoint configured? – Rubens Farias Jan 20 '10 at 10:18
  • Do you have some kind of router/load-balancer in front of your service to introduce redirection problems? – Dmitry Ornatsky Jan 22 '10 at 15:43
  • Yep I use load balancers, and my recent research showed me that these load balancers are the origin of my problems. Thank you for your responses guys. – Selcuk S. Feb 01 '10 at 08:58
  • @SelcukSasoglu hi, I'm having this same issue. Did you have to change any configuration in the load balancers? – Danilo Ruziska Feb 08 '19 at 19:45
  • @DaniloRuziska yes, as I said, I had to change a setting on the load balancer, but as you can imagine after 9 years I do not remember what I have changed anymore. Sorry. Try redirecting only one server from the load balancer first, see if it works. This way you might find a setting difference between your servers. – Selcuk S. Feb 11 '19 at 20:12

4 Answers4

25

had the same problem. i fixed it by adding httpsGetEnabled to serviceBehaviors>behavior like this:

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

maybe it helps someone else. dont think that u need this hint after 4years =)

ich2211
  • 275
  • 4
  • 7
  • 4
    I can't upvote this enough. My issue was I had many services with working WSDLs but one without. The one that didn't work needed to be "http**s**GetEnabled" (with the "s") instead of just "httpGetEnabled". – Turnerj Apr 29 '16 at 07:05
18

You basically need three things to enable browsing to your WSDL for a WCF service:

  1. a service behavior which enables service metadata
  2. set the httpGetEnabled=True on that service metadata behavior to allow http browsing to that metadata
  3. a mex endpoint on your service

So your config on the server side might looks something like this (plus a bit more stuff):

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MetadataBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service behaviorConfiguration="MetadataBehavior" name="YourService">
        <endpoint address="" 
                  binding="basicHttpBinding" 
                  contract="IYourService" />
        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

Points 1 and 2 are handled by this line here:

<serviceMetadata httpGetEnabled="true" />

You need to reference that service behavior in your <service> tag for it to become active.

Point 3 (MEX endpoint) is this section here:

<endpoint address="mex" 
          binding="mexHttpBinding" 
          contract="IMetadataExchange" />

For http, use the mexHttpBinding, and the IMetadataExchange contract is a WCF system contract for metadata exchange .

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I agree. All these configurations were correctly set. I forgot to mention an important detail: the service works fine on my test server, but this error came up when I deployed the service to my production server. Sorry for the inconvenience. – Selcuk S. Jan 20 '10 at 11:53
3

I know that answer it's so late but I had the same problem and the solution was:

Add tags [ServiceContract] and [OperationContract] on interface that it is implemented on service .svc. Visual Studio create interface when you select WCF Service but I deleted the interface and I created my own interface.

[ServiceContract]
public interface IService1
{
    [OperationContract]
    void DoWork();
}

I hope to help somebody.

Rodolfo Luna
  • 829
  • 9
  • 19
-1

Yes the issue is with publishing metadata. Just adding one more tips. You can also add service meta data using code, like this :

ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;

host.Description.Behaviors.Add(smb);

More details here : http://msdn.microsoft.com/en-us/library/aa738489%28v=vs.110%29.aspx

amarnath chatterjee
  • 1,942
  • 16
  • 15