【问题标题】:Web service contains an empty service tagWeb 服务包含一个空的服务标签
【发布时间】:2012-11-16 13:21:25
【问题描述】:

我创建了一个 WCF 服务。

在 WSDL 中,我看不到服务应该绑定的 URL 和 PORT。

我看到的是:

<wsdl:service name="SimpleWebService"/>

知道我做错了什么吗?可能是 web.config 中的某些内容?

<system.serviceModel>
    <client />
    <bindings>
        <webHttpBinding>
            <binding closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
                <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
            </binding>
        </webHttpBinding>
    </bindings>
    <services>
        <service name="WS.OS.SimpleWS" behaviorConfiguration="myServiceBehavior">
            <endpoint name="webHttpBinding" address="" binding="webHttpBinding" contract="WS.OS.SimpleWS" behaviorConfiguration="webHttp" />
            <endpoint name="mexHttpBinding" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="myServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="webHttp">
                <webHttp />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

【问题讨论】:

  • 你能提供你的任何代码吗?配置文件?其他相关源代码?
  • 我用 web.config 更新了帖子
  • 它是否托管在 IIS 中(我猜是因为您在那里有 serviceHostingEnvironment 标记)?

标签: c# .net wcf wsdl wcf-configuration


【解决方案1】:

使用 webHttpBinding 创建端点会创建一个 REST 端点。 REST 端点没有 wsdl。在您的情况下,您会看到 wsdl 生成,因为您已包含元数据行为。您将在 WSDL 中列出一个仅用于 SOAP 端点的端点。这是一篇很好的博文,可以帮助您更好地理解这一点:http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx

【讨论】:

    【解决方案2】:

    查看问题和配置,我假设(我们都知道这会导致)您的服务托管在 IIS 中。因此,给定“”的地址并且没有给出端口,您将不得不查看您的 IIS 设置以找到该服务打开的站点和端口。 http 的默认值为 80,https 的默认值为 443。

    举个简单的例子,如果您的服务位于 IIS 的“默认网站”上,那么您的服务将可能位于:

    http://YourServer/YourService/YourService.svc
    

    如果其中托管的 Web 应用程序位于特定不同的站点下,则需要查看 IIS 的设置才能找到它。让 IIS 将 SVC 托管为 默认 页面也很常见,因此您的 URI 中可能只有前两部分,而不是实际页面。除非您开始深入研究您的网络服务器,否则我认为您不会有太多的运气。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-29
      相关资源
      最近更新 更多