WebGet adds trailing slash inappropriately
I have a rest client which tries to call http://my-server/section1/section2?param1=foo
http://my-server/section1/section2?param1=foo http://my-server/sectionX/sectionY?param2=bar http://my-server/sectionA/sectionC?param3=kuku
notice that the query parameters key name changes (param1, param2,param3...)
The contract I implemented is
[WebGet(UriTemplate = "")]
[OperationContract]
Message MyMethod();
However this will cause the actual uri called to be: http://my-server/section1/section2/?param1=foo
Note that a trailing slash has been added between section2 and ?
Does someone know how to prevent it?
David
PS pls note that 1) a the trick of taking the last segment+ the parameters as a parameter to MyMethod (and usage of UriTemplate="/{lastSegment}) will cause the question mark (?) to be decoded... which will ruin the call requ开发者_运维问答est 2) removing the UriTemplate completely will cause the methodname to be part of the uri...
You really should not use WCF contracts on the client to make calls to REST services. Simply use HTTPWebRequest or HttpClient to make those calls.
精彩评论