Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

how to handle int id param in wcf rest services?

$
0
0

Hello - I'd like to return a Customer object from a WCF REST method based on customer ID.  For example: http://localhost/RestTest.svc/Customers/123

I can successfully use the following OperationContract to do this:

[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Customers/{id}")]
Customer GetCustomer(string id);

I'd rather use an int id parameter instead of string id parameter but I think this may be a constraint of WCF REST services.

Am I stuck with a string id parameter or is there a workaround that will let me define the id parameter as an int?


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>