0
可能重複:
Bad Request 400 while accessing WCF Rest service (WebGet)WebGet方法給出了WCF REST服務應用程序錯誤400 「錯誤的請求」
大家好,
讓我解釋什麼,我有做WCF休息服務。這裏是我的代碼和配置:
IDNNService接口
[ServiceContract] public interface IDNNService { [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "hello/{Name}")] [OperationContract] string SayHello(string Name); }
服務類實現接口
public class DNNService : IDNNService { public string SayHello(string Name) { return string.Format("Hello {0}", Name); } }
配置文件
<system.serviceModel> <services> <service behaviorConfiguration="DNNServiceBehavior" name="DNNService"> <endpoint address="" binding="wsHttpBinding" contract="IDNNService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <endpoint address="rest" binding="webHttpBinding" behaviorConfiguration="httpBehavior" contract="IDNNService"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="DNNServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="httpBehavior"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel>
我能夠生成我的SVC文件與WSDL
返回正確的信息,但問題是,當我嘗試訪問我的實際方法
http://localhost/DC560X_rest/DesktopModules/DNNCentric-RestService/Entities/DNNService.svc/rest/hello/prabhakar
- IE Dispaly 「400錯誤請求」
- Firefox顯示空白頁面
請幫我一把。 在此先感謝
你爲什麼在你的模板裏有兩個'}'? – 2011-01-18 15:24:34