locked
web service RRS feed

  • Question

  • User-1733090791 posted

    i have a program to complete.

    i have to write a web service that have a method that calls an asp.net page with parameters and send a response with parametre in xml format ..

    thanks in advance..

    Tuesday, April 23, 2013 5:55 AM

Answers

  • User220959680 posted

    write a web service that have a method that calls an asp.net page with parameters and send a response with parametre in xml format ..

    Break down the problem into tasks as out lined below.

    1. A WebService with a method that takes parameters and returns the response. Note that WCF can be utilised to implement this. But WCF is more configuration based rather than convention based. Use ASP.NET Web API, which is light weight framework to implement RESTFul web service.

    You need to implement a GET method,which takes parameters from client and return the xml data.

    ASP.NET Web API service can return XML or Json data to the client. Client needs to specify content-type in Http header request.

    //Below is from a unit test that Tests whether the service response is Json
    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri(ConfigurationManager.AppSettings["serviceUri"]);
    
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    HttpResponseMessage response = client.GetAsync("news/getnewscount").Result;
    
    Assert.AreEqual("application/json", response.Content.Headers.ContentType.MediaType);


    2. Client calls the service method and passes the data

    samples here can provide more insight to implement http://www.asp.net/web-api/samples

    when you are struck post your query in relevant forum http://forums.asp.net/1246.aspx/1?ASP+NET+Web+API

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 26, 2013 5:02 AM

All replies

  • Tuesday, April 23, 2013 6:11 AM
  • User71929859 posted

    i have a program to complete.

    i have to write a web service that have a method that calls an asp.net page with parameters and send a response with parametre in xml format ..

    thanks in advance..

    Ah. Wrong place. We are not here to do your homeworks. Google/Bing and learn about web service and start to build your system. If you come up with a specific problem related to asp.net, feel free to post here. We willl try to solve it. Other than that, you can't expect us to do your work for you.

    Thanks!

    Thursday, April 25, 2013 1:07 PM
  • User220959680 posted

    write a web service that have a method that calls an asp.net page with parameters and send a response with parametre in xml format ..

    Break down the problem into tasks as out lined below.

    1. A WebService with a method that takes parameters and returns the response. Note that WCF can be utilised to implement this. But WCF is more configuration based rather than convention based. Use ASP.NET Web API, which is light weight framework to implement RESTFul web service.

    You need to implement a GET method,which takes parameters from client and return the xml data.

    ASP.NET Web API service can return XML or Json data to the client. Client needs to specify content-type in Http header request.

    //Below is from a unit test that Tests whether the service response is Json
    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri(ConfigurationManager.AppSettings["serviceUri"]);
    
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    HttpResponseMessage response = client.GetAsync("news/getnewscount").Result;
    
    Assert.AreEqual("application/json", response.Content.Headers.ContentType.MediaType);


    2. Client calls the service method and passes the data

    samples here can provide more insight to implement http://www.asp.net/web-api/samples

    when you are struck post your query in relevant forum http://forums.asp.net/1246.aspx/1?ASP+NET+Web+API

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 26, 2013 5:02 AM