【发布时间】:2012-11-01 08:06:20
【问题描述】:
我正在编写一个 WCF 服务(json REST),并且在使用 wcftestclient.exe 时它运行良好
当我运行该测试工具时,它会在调试时触发我的断点,并且一切都正常工作。
但是,当使用浏览器导航到服务和方法时,不会触发断点。似乎请求甚至没有到达代码。
我在使用网络浏览器导航到服务时没有收到任何错误,它只是没有获取任何数据,或者触发断点。
抱歉,如果这是重复的,我已经阅读并尝试了在类似问题的答案中找到的许多不同配置,但似乎没有任何效果。
非常感谢您的帮助,我已经在下面发布了我的代码。
马丁
我有设置: 服务合约
[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
List<Country> GetAllCountries();
服务类:
public List<Country> GetAllCountries()
{
ControlServiceRepository rep = new ControlServiceRepository();
return rep.GetAllCountries().ToList() ;
}
和我的网络配置
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="OmniData" behaviorConfiguration="ServiceConfig">
<!-- Service Endpoints -->
<host>
<baseAddresses>
<add baseAddress="http://localhost:55641/"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" contract="ControlService.IOmniData" behaviorConfiguration="rest" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="rest">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceConfig">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
【问题讨论】:
-
你是从同一个域调用服务吗?
-
我目前只是想通过 Visual Studio 让它工作,我已经将它上传到 iis7,它是完全一样的。网络浏览器调用是:localhost:55641/OmniData.svc/GetAllStores
-
GetAllStores或GetAllCountries? -
大声笑,上帝帮助我...太长了,GetAllCountries
-
您可以在测试工具运行时使用Fiddler,看看它如何调用您的服务
标签: c# wcf rest wcf-binding