F5后WCF服务主机不上来 [英] WCF Service Host does not come up after F5

查看:26
本文介绍了F5后WCF服务主机不上来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF 4 服务项目.我按 F5 但它只带我到 http://localhost 并显示文件目录.不知道为什么它没有运行 WCF 服务主机.我将我的 WCF 服务项目设置为启动项目.

 <基本HttpBinding><绑定名称="soapBinding"><security mode="None"></security></binding></basicHttpBinding><!-- 启用 RESTful 端点--><webHttpBinding><binding name="webBinding"></binding></webHttpBinding>

例如,如果我要将其添加到另一个 C# 项目并通过服务引用添加,这确实会创建 WSDL.这就是为什么我不明白为什么在我指定相同的 url(我刚刚添加到 C# 项目中的那个,它 DID 创建了一个 wsdl 所以我知道它可以工作)测试客户端不会显示任何内容后,测试客户端说在我点击后添加好的,但在测试客户端 UI 中显示它已成功添加后,它绝对没有显示任何内容.我在另一台开发机器上试过,他对我的服务也有同样的待遇.

更新 - 更多关于设置的信息:

WCF 服务项目中的 Web.config

 

解决方案

我通常确保解决方案在调试模式(而非发布)下运行,并且启动文件是 servicename.svc 文件.看看 关于启动 WCF 测试客户端的提示 为您的问题提供更多提示.

您能否分享您的合同定义,因为此处可能存在与不受支持的合同有关的问题...如果您查看 此链接,您将看到包含以下列表的帖子.

<块引用>

以下是 WCF 测试客户端不支持的功能列表:

  • 类型:流、消息、XmlElement、XmlAttribute、XmlNode,类型实现 IXmlSerializable 接口,包括相关的XmlSchemaProviderAttribute 属性,以及 XDocument 和 XElement类型、ADO.NET DataTable 类型和 DataSet 类型(以及它的类型派生类).
  • 双重合同.
  • 交易.
  • 安全性: CardSpace 、证书和用户名/密码.
  • Bindings:WSFederationbinding,任何上下文绑定和 Https 绑定,WebHttpbinding(Json 响应消息支持).

I have a WCF 4 Service project. I press F5 but it just takes me to http://localhost and shows the file directory. Not sure why it's not running the WCF Service Host. I have my WCF service project set as the startup project.

  <!-- SOAP Binding -->
  <basicHttpBinding>
    <binding name ="soapBinding">
        <security mode="None"></security>
    </binding>
  </basicHttpBinding>

  <!-- Enable RESTful Endpoints-->
  <webHttpBinding>
      <binding name="webBinding"></binding>
  </webHttpBinding>

This DOES create a WSDL if I were to add it to another C# project for example and add via service reference. That's why I can't see why the test client would not show anything after I specified the same url (the one I just added to a C# project which DID create a wsdl so I know it works) the test client says added after I click OK but shows absolutely nothing in the test client UI right after it says it added it successfully. I tried on another dev machine, he gets the same deal with my service.

UPDATED - More info from my side on setup:

Web.config in our WCF Service project

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>

  <system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
        <serviceActivations>
            <add relativeAddress="Events.svc" service="OurCompany.API.OurService"/>
        </serviceActivations>
    </serviceHostingEnvironment>

    <bindings>

      <!-- SOAP Binding -->
      <basicHttpBinding>
        <binding name ="soapBinding">
            <security mode="None"></security>
        </binding>
      </basicHttpBinding>

      <!-- Enable RESTful Endpoints-->
      <webHttpBinding>
          <binding name="webBinding"></binding>
      </webHttpBinding>

    </bindings>


    <behaviors>

      <endpointBehaviors>

        <!-- allow XML REST -->
        <behavior name="poxBehavior">
            <webHttp defaultOutgoingResponseFormat="Xml" automaticFormatSelectionEnabled="true"/>
        </behavior>

        <!--<behavior name="jsonBehavior"><enableWebScript/></behavior>-->
        <!-- allow JSON REST -->
        <behavior name="jsonBehavior">
            <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json"/>
        </behavior>

      </endpointBehaviors>

      <serviceBehaviors>

        <behavior name="defaultBehavior">
            <serviceDebug includeExceptionDetailInFaults="true" />
            <serviceMetadata httpGetEnabled="true" />
        </behavior>

      </serviceBehaviors>

    </behaviors>


    <services>

      <service name="EventInventory.API.Events" behaviorConfiguration="defaultBehavior">
          <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
          <!--<endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="soapBinding" contract="OurCompany.API.IOurService" />-->
          <!-- <endpoint address="json" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="jsonBehavior" contract="OurCompany.API.IOurService" />-->
          <!--<endpoint address="xml" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="poxBehavior" contract="OurCompany.API.IOurService" />-->
          <endpoint binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="jsonBehavior" contract="OurCompany.API.IOurService" />
      </service>

    </services>

  </system.serviceModel>


  <system.webServer>

    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>

  </system.webServer>

</configuration>

Visual Studio look at the project

(right click the image and choose to view in a new tab and you'll be able to see the jpeg clearly, at 100% size)

解决方案

I usually make sure the solution is running in Debug mode (not release) and that the startup file is the servicename.svc file. Take a look at Tips for Launching WCF Test Client for some more hints on your issue.

Can you share your contract definitions, as there might be an issue here with regard to a non-supported contract...if you take a look at this link, you will see a post with the following list.

The following is a list of features not supported by WCF Test Client:

  • Types: Stream, Message, XmlElement, XmlAttribute, XmlNode, types that implement the IXmlSerializable interface, including the related XmlSchemaProviderAttribute attribute, and the XDocument and XElement types, the ADO.NET DataTable type and the DataSet type (as well as its typed-derived classes).
  • Duplex contract.
  • Transaction.
  • Security: CardSpace , Certificate, and Username/Password.
  • Bindings:WSFederationbinding, any Context bindings and Https binding, WebHttpbinding (Json response message support).

这篇关于F5后WCF服务主机不上来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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