REST Web服务方法中的数据类型限制

时间:2021-03-13 17:14:25

Is there any restriction on the data types that the input parameter that is present in URI has to be string in REST Webservice?

对于URI中存在的输入参数必须是REST Webservice中的字符串,数据类型是否有任何限制?

I am creating a REST Webservice. The method has an input paramter Id and this present in the URI as well. If I change type to integer, it generates error when calling it.

我正在创建一个REST Web服务。该方法具有输入参数Id,并且它也存在于URI中。如果我将类型更改为整数,则在调用它时会生成错误。

Operation 'Get' in contract 'IService1' has a path variable named 'id' which does not have type 'string'.  Variables for UriTemplate path segments must have type 'string'. 

1 个解决方案

#1


1  

WCF REST in .net 4 is not capable of doing this conversion, however WCF Web API can. http://wcf.codeplex.com

.net 4中的WCF REST无法进行此转换,但WCF Web API可以。 http://wcf.codeplex.com

This has nothing to do with any constraints of REST it is purely a limitation of the implementation framework.

这与REST的任何约束无关,它纯粹是对实现框架的限制。

#1


1  

WCF REST in .net 4 is not capable of doing this conversion, however WCF Web API can. http://wcf.codeplex.com

.net 4中的WCF REST无法进行此转换,但WCF Web API可以。 http://wcf.codeplex.com

This has nothing to do with any constraints of REST it is purely a limitation of the implementation framework.

这与REST的任何约束无关,它纯粹是对实现框架的限制。