Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:45:20+00:00 2026-06-14T05:45:20+00:00

I’ve set up the following interface. [ServiceContract] public interface IService1 { [OperationContract] String Ping();

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:45:21+00:00Added an answer on June 14, 2026 at 5:45 am

    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

    [ServiceContract]
    public interface IRestService
    {
      [OperationContract]
      [WebInvoke(Method = "GET", 
        ResponseFormat = WebMessageFormat.Xml, 
        BodyStyle = WebMessageBodyStyle.Wrapped, 
        UriTemplate = "xml/{id}")]
      String XmlData(String id);
    
      [OperationContract]
      [WebInvoke(Method = "GET", 
        ResponseFormat = WebMessageFormat.Json, 
        BodyStyle = WebMessageBodyStyle.Wrapped, 
        UriTemplate = "json/{id}")]
      String JsonData(String id);
    }
    

    RestService.svc.cs – the implementation, what your code actually does to the client

    public class RestService : IRestService
    {
      public String XmlData(String id)
      {
        return "Requested XML of id " + id;
      }
    
      public String JsonData(String id)
      {
        return "Requested JSON of id " + id;
      }
    }
    

    Web.config – the configuration, what your code is handled as on the way to the client

    <configuration>
    
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
    
      <system.serviceModel>
        <services>
          ...
        </services>
        <behaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>
    

    services – contents of the tag describing the service’s nature

    <service name="DemoRest.RestService" 
             behaviorConfiguration="ServiceBehavior">
      <endpoint address="" binding="webHttpBinding" 
                contract="DemoRest.IRestService" 
                behaviorConfiguration="web"></endpoint>
    </service>
    

    behaviors – contents of the tag describing the behavior of the service and the end-point

    <serviceBehaviors>
      <behavior name="ServiceBehavior">
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
    
    <endpointBehaviors>
      <behavior name="web">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
    

    Index.html – the executor, what your code can be called as

    <html>
      <head>
        <script>
          ...
        </script>
        <style>
          ...
        </style>
      </head>
      <body>
        ...
      </body>
    </html>
    

    script – contents of the tag describing the executable in JavaScript

    window.onload = function () {
      document.getElementById("xhr").onclick = function () {
        var xhr = new XMLHttpRequest();
        xhr.onload = function () { alert(xhr.responseText); }
        xhr.open("GET", "RestService.svc/xml/Viltersten");
        xhr.send();
      }
    }
    

    style – contents of the tag describing the appearance

    .clickable
    {
      text-decoration: underline;
      color: #0000ff;
    }
    

    body – contents of the tag describing the markup structure

    <ul>
      <li>XML output <a href="RestService.svc/xml/123">
        <span class="clickable">here</span></a></li>
      <li>JSON output <a href="RestService.svc/json/123">
        <span class="clickable">here</span></a></li>
      <li>XHR output <span id="xhr" class="clickable">here</span></li>
    

    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 of using as well as the XML version declaration are omitted for spacial reasons.

    Now the response can be retrieved using the following URL.

    localhost:12345/RestService.svc/xml/Konrad
    localhost:12345/RestService.svc/json/Viltersten
    
    1. Does anybody else get it to work too?
    2. Any suggestions on improvement or clarification?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.