空/空的WSDL文件 [英] Blank/Empty WSDL file

查看:151
本文介绍了空/空的WSDL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎,有我的WCF Web服务输出,至今没有运气(这是空的?)。

I'm struggling to have my WCF web service output a wsdl file with no luck so far (it's empty?).

在SVC文件:

<%@ ServiceHost Language="C#" Debug="true" Service="xxx.WCF.SubsetMID" CodeBehind="SubsetMID.svc.cs"
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
%>

在CS文件:

namespace xxx.WCF
{
    [ServiceContract(Namespace = "SubsetMID")]
    public interface ISubsetMID
    {
        [OperationContract]
        [WebInvoke(BodyStyle=WebMessageBodyStyle.Wrapped)]
        long[] GetMIDs(Guid guid, int subsetID);
    }

    [DataContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class SubsetMID : ISubsetMID
    {
        public long[] GetMIDs(Guid guid, int subsetID)
        {
            [...]

            return returnValue;
        }
    }
}

我的网络配置文件:

My web config file :

<system.serviceModel>
  <services>
    <service name="xxx.WCF.SubsetMID">
      <endpoint address=""
                binding="wsHttpBinding"
                contract="xxx.WCF.ISubsetMID" />

      <endpoint address="mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment
      multipleSiteBindingsEnabled="true"
      aspNetCompatibilityEnabled="true"
  />
</system.serviceModel>

当我访问WSD(? HTTP://.../SubsetMID.svc WSDL )我没有得到任何错误,但它只是一个空白页。

I don't get any error when I access the wsd (http://.../SubsetMID.svc?wsdl) but it's just a blank page.

推荐答案

以下是基于一些研究,我做了一个最好的猜测 - 我没那么熟悉的RESTful WCF服务,所以我可能是错的,但是这应该给你一个起点,至少。

The following is a best guess based on some research I did - I'm not that familiar with RESTful WCF services, so I might be wrong but this should give you a starting point at least.

您没有指定,但它看起来像你试图写一个RESTful WCF服务。我不能完全肯定,因为您在您的端点使用的wsHttpBinding ,但你也装点在服务方法, [WebInvoke]

You didn't specify, but it looks like you're trying to write a RESTful WCF service. I'm not entirely certain, because you use wsHttpBinding in your endpoint, but you also decorate the method in the service with [WebInvoke].

在任何情况下,REST服务没有WSDL中 - 这是一个SOAP的事情。此外,我相信WCF支持与的WebHttpBinding REST。当您使用 WebServiceHostFactory 在你的.svc文件,我觉得这是正在发生的事情:

In any event, REST services do not have WSDLs - that's a SOAP thing. Additionally, I believe WCF supports REST with the webHttpBinding. As you are using WebServiceHostFactory in your .svc file, I think this is what is happening:

您没有定义任何的WebHttpBinding 端点。 WCF将创建一个默认的的WebHttpBinding 终端,基于.svc文件的位置的地址。然而,当默认的端点根据使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webservicehost.aspx?cs-save-lang=1&cs-lang=csharp#$c$c-snippet-1\"相对=nofollow> WebServiceHost类的:

You do not have any webHttpBinding endpoints defined. WCF will create a default webHttpBinding endpoint, with the address based on the location of the .svc file. However, when default endpoints are used according to WebServiceHost Class:

...的WebServiceHost还会禁用HTTP帮助页面和Web服务描述语言(WSDL)GET功能,因此元数据端点不使用默认的HTTP端点干扰。

如果你正在编写一个REST服务,您将不再需要一个WSDL。如果你在有一个SOAP服务计划,然后用你的.svc文件 ServiceHostFactory 和删除 [WebInvoke] 从方法属性。

If you're writing a REST service, you won't need a WSDL. If you're planning on having a SOAP service, then use ServiceHostFactory in your .svc file and remove the [WebInvoke] attribute from the method.

再次,这是一个(相对)的猜测,这可能是错误的,但它是一个起点。

Again, this is a (relatively) educated guess, and it may be wrong, but it's a place to start.

这篇关于空/空的WSDL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆