WCF hosting: Can access svc file but cannot go to wsdl link

前端 未结 4 1782
借酒劲吻你
借酒劲吻你 2021-02-12 12:31

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 ser

相关标签:
4条回答
  • 2021-02-12 13:06

    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 =)

    0 讨论(0)
  • 2021-02-12 13:14

    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.

    0 讨论(0)
  • 2021-02-12 13:20

    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

    0 讨论(0)
  • 2021-02-12 13:22

    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 .

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