无法使WCFExtras与WCF服务一起使用

时间:2012-05-21 21:14:19

标签: wcf wsdl

我收到一个错误,我无法提取该服务的元数据。当我查看WCFExtras样本时,它看起来都很好,样本工作正常。唯一的区别是我的WCF服务是.NET 4.0。

这就是我的web.config的样子:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>

    <customErrors mode="Off" />

  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <validation validateIntegratedModeConfiguration="false" />
    <directoryBrowse enabled="true" />
  </system.webServer>

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="CDITecServices.TECServiceHelperBehavior"
               name="CDITecServices.ITECServiceHelper">
        <endpoint address=""
          behaviorConfiguration="CDITecServices.TECServiceHelperEndpointBehavior"
          binding="basicHttpBinding" contract="CDITecServices.ITECServiceHelper"/>
      </service>
    </services>


    <behaviors>
      <endpointBehaviors>
        <behavior name="CDITecServices.TECServiceHelperEndpointBehavior">
          <wsdlExtensions singleFile="True"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="CDITecServices.TECServiceHelperBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"
                        httpHelpPageEnabled="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <!-- Declare that we have an extension called WSDL Extras-->
        <add name="wsdlExtensions"
             type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0,
                   Culture=neutral, PublicKeyToken=null"/>
      </behaviorExtensions>
    </extensions>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
                               multipleSiteBindingsEnabled="true"/> 
  </system.serviceModel>


</configuration>


这就是我的界面:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using WCFExtras.Wsdl.Documentation;

namespace CDITecServices
{
    [XmlComments]
    [ServiceContract]
    public interface ITECServiceHelper
    {

        [OperationContract]
        void DownloadDataFile(string OrderTicketId, string Username,
                              string Password, string UserDatabase);

        [OperationContract]
        List<string> GetRecordsFromFile(string OrderTicketId, ref long StartIndex);

        // TODO: Add your service operations here
    }
}

1 个答案:

答案 0 :(得分:1)

将您的服务名称从CDITecServices.ITECServiceHelper更新为班级名称CDITecServices.TECServiceHelper

<service behaviorConfiguration="CDITecServices.TECServiceHelperBehavior" name="CDITecServices.TECServiceHelper">

&lt; service&gt;上的name属性tag必须与服务类的名称匹配,完全限定,包括名称空间。