uritemplate

Getting Gibberish instead of Hello World from a service with webHttpBinding

一世执手 提交于 2019-12-25 03:21:54
问题 Here is a trivial example that is supposed to return "Hello World" string. However, a browser displays something like SGVsbG8gV29ybGQ= . Which is the right way to return plain text from an oldskul-style service? please know that: I can't return a string: three Unicode characters will be automatically prepended and the legacy HTTP client won't be able to interoperate. I could return a Message , but still must keep parsing functionality to extract the data variable. Mixing Message and int types

Is it possible to have “overloaded” uritemplates?

旧街凉风 提交于 2019-12-23 07:48:32
问题 [OperationContract] [WebGet(UriTemplate = "/searchresults/{searchTerm}/{searchType}", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)] Message GetSearchResults(string searchTerm, string searchType); [OperationContract] [WebGet(UriTemplate = "/searchresults/{searchTerm}", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)] Message GetSearchResults(string searchTerm

Is it possible to have “overloaded” uritemplates?

一曲冷凌霜 提交于 2019-12-23 07:48:23
问题 [OperationContract] [WebGet(UriTemplate = "/searchresults/{searchTerm}/{searchType}", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)] Message GetSearchResults(string searchTerm, string searchType); [OperationContract] [WebGet(UriTemplate = "/searchresults/{searchTerm}", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)] Message GetSearchResults(string searchTerm

Optional path variables in Spring-MVC RequestMapping URITemplate

时光怂恿深爱的人放手 提交于 2019-12-21 07:56:29
问题 I have the following mapping: @RequestMapping(value = "/{first}/**/{last}", method = RequestMethod.GET) public String test(@PathVariable("first") String first, @PathVariable("last") String last) {} Which for the following URIs: foo/a/b/c/d/e/f/g/h/bar foo/a/bar foo/bar maps foo to first and bar to last and works fine. What I would like is something that maps everything between foo and bar into a single path param, or null if there is no middle (as in the last URI example): @RequestMapping

Can URI templates be used to match URIs to routes?

不羁的心 提交于 2019-12-21 03:51:57
问题 Frameworks like ASP.NET or Nancy provide a syntax that can be used for specifying routes, such as: MapRoute("/customers/{id}/invoices/{invoiceId}", ...) In ASP.NET routes work in two directions. They can match a request URI such as /customers/32/invoices/19 to a route, and they can resolve parameters such as { id: 37, invoiceId: 19 } into a URI. RFC 6570: URI Templates also defines a similar, though much richer, specification for URI's that are often used to resolve URI's. For example:

Using query string parameters to disambiguate a UriTemplate match

不羁岁月 提交于 2019-12-20 17:04:12
问题 I am using WCF 4.0 to create a REST-ful web service. What I would like to do is have different service methods called based on query string parameters in the UriTemplate . For example, I have an API that allows users to retrieve information about a person using either by their driver's license or their social security number as a key. In my ServiceContract / interface I would define two methods: [OperationContract] [WebGet(UriTemplate = "people?driversLicense={driversLicense}")] string

What is the best way to design a HTTP request when somewhat complex parameters are needed?

谁都会走 提交于 2019-12-17 21:52:14
问题 I have some web services that I am writing and I am trying to be as RESTful as possible. I am hosting these web services using a HTTPHandler running inside of IIS/ASP.NET/SharePoint. Most of my services expect a HTTP GET. I have two of these that are simply returning some data (i.e., a query) and will be Idempotent, but the parameters may be somewhat complex. Both of them could include characters in the parameters of the service that are not allowed for at least the PATH portion of the URL.

Can URI templates be used to match URIs to routes?

会有一股神秘感。 提交于 2019-12-03 12:00:59
Frameworks like ASP.NET or Nancy provide a syntax that can be used for specifying routes, such as: MapRoute("/customers/{id}/invoices/{invoiceId}", ...) In ASP.NET routes work in two directions. They can match a request URI such as /customers/32/invoices/19 to a route, and they can resolve parameters such as { id: 37, invoiceId: 19 } into a URI. RFC 6570: URI Templates also defines a similar, though much richer, specification for URI's that are often used to resolve URI's. For example: UriTemplate("/customers/{id}/invoices{/invoiceId}{?sort}", { id: 37, invoiceId: 19, sort: 'asc' } ) //

Using query string parameters to disambiguate a UriTemplate match

。_饼干妹妹 提交于 2019-12-03 04:39:14
I am using WCF 4.0 to create a REST-ful web service. What I would like to do is have different service methods called based on query string parameters in the UriTemplate . For example, I have an API that allows users to retrieve information about a person using either by their driver's license or their social security number as a key. In my ServiceContract / interface I would define two methods: [OperationContract] [WebGet(UriTemplate = "people?driversLicense={driversLicense}")] string GetPersonByLicense(string driversLicense); [OperationContract] [WebGet(UriTemplate = "people?ssn={ssn}")]

Optional parameter in UriTemplate in WCF

核能气质少年 提交于 2019-12-02 04:51:12
问题 I've used the hint in this thread and provided a default value, so that when a user doesnät specify the virutal sub-directory, I'm making the assumption that he meant all the stuff to be listed. It works. [OperationContract] [WebInvoke(UriTemplate = "GetStuff/{type=all}", ...] IEnumerable<Stuff> GetStuff(String type); However, it would be nicer to specify a default value, instead. However, default(String) is null and I'd like to sent in an actual value. Particularly, I've set my heart on