2011-04-19 51 views
0

再一次,作为WCF,MVC和Sharp Architecture的初学者,我可能会问一个愚蠢的问题,请耐心等待。制作WCF Northwind Sharp Architecture作品

我终于能够做出夏普架构的Northwind案例。

我可以使用互联网浏览器浏览服务 本地主机/ NorthwindWcfServices/TerritoriesService.svc 本地主机/ NorthwindWcfServices/TerritoriesService.svc?WSDL

我可以用WcfTestClient.exe

,然后调用服务GetTerritories我使用Fiddler来测试它: 提琴手是确定的,当我要求一个GET: 本地主机/ NorthwindWcfServices/TerritoriesService.svc WSDL

当我开始要求 localhost/NorthwindWcfServices/TerritoriesService.svc/GetTerritories

他们不断给我一个400错误的请求错误。

有什么我应该做的,使其工作?

我应该在fiddler头部请求中添加内容类型吗?或者我应该在服务类中添加任何属性?

任何帮助将不胜感激。

感谢

回答

0

你必须使用Web配置文件的例子来配置服务如果u配置WCF访问...您服务的配置应该是这个样子

<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <behavior name="EndPBehavior"> 
     <webHttp/> 
     <enableWebScript/> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<services> 
    <service behaviorConfiguration="ServiceBehavior" name="CastleTest.WCF.WCFService"> 
    <endpoint address="" binding="webHttpBinding" 
       contract="CastleTest.WCF.IWCFService" 
       behaviorConfiguration="EndPBehavior"/> 
    </service> 
</services> 

试试看看错误400是否变为