我有一个 WCF 4 服务项目。我按 F5 但它只是带我进入http://localhost
并显示文件目录。不知道为什么它没有运行 WCF 服务主机。我将我的 WCF 服务项目设置为启动项目。
<!-- SOAP Binding -->
<basicHttpBinding>
<binding name ="soapBinding">
<security mode="None"></security>
</binding>
</basicHttpBinding>
<!-- Enable RESTful Endpoints-->
<webHttpBinding>
<binding name="webBinding"></binding>
</webHttpBinding>
例如,如果我要将它添加到另一个 C# 项目并通过服务引用添加,这会创建一个 WSDL。这就是为什么我看不到为什么在我指定相同的 url 后测试客户端不会显示任何内容(我刚刚添加到 C# 项目中的那个 DID 创建了一个 wsdl,所以我知道它有效)测试客户端说在我点击后添加好的,但在它说它成功添加它之后,测试客户端 UI 中绝对没有显示任何内容。我在另一台开发机器上试过,他对我的服务也有同样的待遇。
更新 - 我这边关于设置的更多信息:
我们的 WCF 服务项目中的 Web.config
<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 看项目