I’ve set up the following interface.
[ServiceContract]
public interface IService1
{
[OperationContract]
String Ping();
}
Its implementation is as follows.
public class Service1 : IService1
{
public string Ping(){ return "Pong"; }
}
According to the testing application in VS it’s working properly when invoked. My problem is that I’d like the text to appear on the screen when I type http://localhost:12345/Service1.svc (or maybe Service1.svc?Ping or Service.svc/Ping). Is it totally off or am I barking up the right tree?
Of course, “Pong” will eventually be an XML strucure.
EDIT
The set-up presented in the reply by @carlosfigueira below gives a good structure to a suggestion for a solution but unfortunately leads on my machine to an error message when run using F5. It seems that metadata is required and that the same goes for endpoints.
I finally got totally PO and went off to business full contact. This is what I’ve produced – it works on my machine and I hope it’s not a local phenomenon. 🙂
IRestService.cs – the declaration, what your code promises to a contacting client
RestService.svc.cs – the implementation, what your code actually does to the client
Web.config – the configuration, what your code is handled as on the way to the client
services – contents of the tag describing the service’s nature
behaviors – contents of the tag describing the behavior of the service and the end-point
Index.html – the executor, what your code can be called as
script – contents of the tag describing the executable in JavaScript
style – contents of the tag describing the appearance
body – contents of the tag describing the markup structure
Everything is stored in a project called
DemoRest. I created my own files for declaration and implementation of the service, removing the default ones. The directives ofusingas well as the XML version declaration are omitted for spacial reasons.Now the response can be retrieved using the following URL.