how to submit datetime parameter to a WCF REST service

13,703

Solution 1

I finally found an answer to my question. to invoke the operation from the browser, I use :

   http://localhost:8080/service/ctrService.svc/isContractUpToDate?contractId='1'&lastmodifieddate='2012/02/04 00:00:00'

and to do it from a .NET client, I use :

    IEnumerable<bool> resp = service.Execute<bool>(new Uri("http://localhost:8080/pricingservice/PricingDataService.svc/isContractUpToDate?contractId='1'&" +"lastmodifieddate='"+DateTime.Now.ToString()+"'"));

        Console.WriteLine("is contract uptodate ? " + resp.First());

Solution 2

We can access RESTful WCF browser services like this

http://localhost:8080/Service/isContractUpToDate/{contractId}/{lastmodifiedDate}

But I think we can't specify DateTime datatype, as per my understanding it should be string only.

Solution 3

I have found this series to be extremely helpful and rich with examples on how to implement WCF REST services (including query strings and filters as well as calling from client code).

Share:
13,703
Attilah
Author by

Attilah

Updated on June 05, 2022

Comments

  • Attilah
    Attilah almost 2 years

    I have a WCF Data service operation :

    [WebGet]
    public bool isContractUpToDate(string contractId, string lastmodifiedDate);
    

    but I don't know how to call this service from a .NET client application and how I can call this operation from Internet Explorer. I'm looking for some examples.