WebGet method gives error 400 "Bad Request" in WCF REST Service Application [duplicate]
Possible Duplicate:
Bad Request 400 while accessing WCF Rest service (WebGet)
Hi All,
Let me explain what I am doing with WCF rest service. Here's my code and config:
IDNNService interface
[ServiceContract] public interface IDNNService { [WebGet(ResponseFormat = WebMessageFormat.Xml, UriTemplate = "hello/{Name}")] [OperationContract] string SayHello(string Name); }
Service class that implements the interface
public class DNNService : IDNNService { public string SayHello(string Name) { return string.Format("Hello {0}", Name); } }
Configuration file
<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>
I am able to generate my SVC file that return correct information with wsdl
But 开发者_StackOverflow中文版the problem is when i try to access my actual method
http://localhost/DC560X_rest/DesktopModules/DNNCentric-RestService/Entities/DNNService.svc/rest/hello/prabhakar
- IE Dispaly "400 Bad Request"
- Firefox Display Blank Page
Please help me out. Thanks in advance
Your URL looks nutty as squirrel etc.
Set a URL for the service
<system.serviceModel>
<services>
<service behaviorConfiguration="DNNServiceBehavior" name="DNNService">
<endpoint
address="http://*:12345/Derp"
binding="wsHttpBinding"
contract="IDNNService">
<identity>
(you may or may not have to ensure port 12345 is unblocked by your firewall)
then use the url: http://localhost:12345/Derp
(of course, from the same machine it is installed on) to test your service.
精彩评论