wcf - 无法让 WCFExtras 与 WCF 服务配合使用

标签 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
    }
}

最佳答案

将服务名称从 CDITecServices.ITECServiceHelper 更新为类名 CDITecServices.TECServiceHelper

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

标记上的名称属性必须与您的服务类的名称匹配,完全限定,包括命名空间。

关于wcf - 无法让 WCFExtras 与 WCF 服务配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10692710/

相关文章:

xml - 使用 Kotlin 解析 XML?

wcf 使用扁平化 WSDL 从 WCF 服务中提取 wsdl

java - 如何在json post请求中发送字节数组?

WCF 服务引用不会重用现有程序集中的类型(VS 2010 Beta 2)

php - 在 php 中强制重新缓存 WSDL

java - WSDL导入问题Delphi XE2

.net - 无法在 Windows 8.1 上安装 TCP 激活

.net - "Leaking"线程句柄

c# - 从 WSDL 文件读取 minOccurs 和默认值

xml - pear SOAP XML 请求