Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF WSDL不显示任何操作/方法_C#_.net_Web Services_Wcf_Wsdl - Fatal编程技术网

C# WCF WSDL不显示任何操作/方法

C# WCF WSDL不显示任何操作/方法,c#,.net,web-services,wcf,wsdl,C#,.net,Web Services,Wcf,Wsdl,我有一个简单的WCF服务,目前在本地运行: http://localhost:63951/WcfService.svc 这将显示默认站点。将?wsdl附加到URL时出现问题: http://localhost:63951/WcfService.svc?wsdl 与我预期的不同,此WDSL文档不显示任何操作/方法 IWcfService: using System.Collections.Generic; using Ant.Domain.Model.DTO; using System.Se

我有一个简单的WCF服务,目前在本地运行:

http://localhost:63951/WcfService.svc
这将显示默认站点。将?wsdl附加到URL时出现问题:

http://localhost:63951/WcfService.svc?wsdl

与我预期的不同,此WDSL文档不显示任何操作/方法

IWcfService:

using System.Collections.Generic;
using Ant.Domain.Model.DTO;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Ant.Application.Service
{
    public interface IApplicationService
    {
        FileDTO GetFile(FileDTO fileDTO);
    }
}
using System.ServiceModel;
using System.ServiceModel.Activation;
using Ant.Application.Service;
using Ant.Domain.Model.DTO;
using Ant.WcfService.Utils;


namespace Ant.WcfService
{
    [ServiceContract(Namespace = "")]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WcfService : ServiceWExceptionManager 
    {
        ApplicationService ApplicationSevice = new ApplicationService();

        [OperationContract]
        public FileDTO GetFile(FileDTO fileDTO)
        {
            return this.Process(() =>
            {
                return this.ApplicationSevice.GetFile(fileDTO);
            });
        }
    }
}
<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Ant.WcfService.WcfService">
        <endpoint address="" behaviorConfiguration="Ant.WcfService.WcfServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="Ant.WcfService.WcfService" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="Ant.WcfService.WcfServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
WCF服务:

using System.Collections.Generic;
using Ant.Domain.Model.DTO;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Ant.Application.Service
{
    public interface IApplicationService
    {
        FileDTO GetFile(FileDTO fileDTO);
    }
}
using System.ServiceModel;
using System.ServiceModel.Activation;
using Ant.Application.Service;
using Ant.Domain.Model.DTO;
using Ant.WcfService.Utils;


namespace Ant.WcfService
{
    [ServiceContract(Namespace = "")]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WcfService : ServiceWExceptionManager 
    {
        ApplicationService ApplicationSevice = new ApplicationService();

        [OperationContract]
        public FileDTO GetFile(FileDTO fileDTO)
        {
            return this.Process(() =>
            {
                return this.ApplicationSevice.GetFile(fileDTO);
            });
        }
    }
}
<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Ant.WcfService.WcfService">
        <endpoint address="" behaviorConfiguration="Ant.WcfService.WcfServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="Ant.WcfService.WcfService" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="Ant.WcfService.WcfServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
Web.config:

using System.Collections.Generic;
using Ant.Domain.Model.DTO;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Ant.Application.Service
{
    public interface IApplicationService
    {
        FileDTO GetFile(FileDTO fileDTO);
    }
}
using System.ServiceModel;
using System.ServiceModel.Activation;
using Ant.Application.Service;
using Ant.Domain.Model.DTO;
using Ant.WcfService.Utils;


namespace Ant.WcfService
{
    [ServiceContract(Namespace = "")]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WcfService : ServiceWExceptionManager 
    {
        ApplicationService ApplicationSevice = new ApplicationService();

        [OperationContract]
        public FileDTO GetFile(FileDTO fileDTO)
        {
            return this.Process(() =>
            {
                return this.ApplicationSevice.GetFile(fileDTO);
            });
        }
    }
}
<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Ant.WcfService.WcfService">
        <endpoint address="" behaviorConfiguration="Ant.WcfService.WcfServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="Ant.WcfService.WcfService" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="Ant.WcfService.WcfServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

什么会导致WCF.svc服务在WSDL文档中不显示任何操作

也许这是一个愚蠢的问题,但使用谷歌,我找不到答案。
英语也不是我的母语;请原谅键入错误。

当您尝试使用API时,这是否正常。@ShujaatSiddiqui我尝试使用SoapUI发出一些请求,但没有成功。请使用上述web中的代码替换。请尝试此操作,因为我可以看到您正在导入WSDL文件