How can I implement a custom QueryStringConverter for RESTful WCF?

I've implemented a customized QueryStringConverter class and hooked it up using a customized WebHttpBehavior subclass. When I make a service call, it hits my breakpoint in the CanConvert override (and I return true for this parameter), but it never calls my ConvertStringToValue override, and ends up just passing null to the service call... why is ConvertStringToValue never called and how can I fix it?

This is not possible. Microsoft were so sloppy with the implementation of this functionality that they merely newed up the standard QueryStringConverter instread of using the one configured in the configuration file.

There are no work arounds that actually work. The second one in the bug report doesn't actually work at all.

The short answer is that you cannot. See the bug here: http://connect.microsoft.com/VisualStudio/feedback/details/616486/bug-with-getquerystringconverter-not-being-called-by-webservicehost#tabs

It is still broken in framework 4.0. My guess is that it's not important - so perhaps take the time to increase the counts on the bug.

Regards

Craig.

How To: QueryStringConverter in WCF Using VB.Net, This is not possible. Microsoft were so sloppy with the implementation of this functionality that they merely newed up the standard QueryStringConverter instread  Resources returned in response to a GET request can be cached in many different ways. Conditional GET, which is a way that a client can check with the service if his version of the data is still the current version, is an optional implementation detail a RESTful endpoint can implement that can further improve speed and scalability.

I know it is quite old question. For any one who looking for some answer, you should be able to add the TypeConverter to your class which can convert type to and from string representation

http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.querystringconverter.aspx

Types that have a TypeConverterAttribute that can convert the type to and from a string representation.

How to create a JSON WCF RESTful Service in 60 seconds , How can I implement a custom QueryStringConverter for RESTful WCF? - wcf. Convert WCF Service to RESTFUL Service. This article explains how to convert WCF to RESTFUL Service in easy steps. To convert WCF to RESTFUL service, an operation contract needs to be decorated with “WebInvoke (or) WebGet” to define the Request and Response format as mentioned below.

Do some thing like this:

In contract file

    [OperationContract]
   [WebGet(UriTemplate = "/TabelasAuxiliares?requestex={requestex}", ResponseFormat = WebMessageFormat.Xml)]
        CadastrodeEscolasResponse TabelasAuxiliares(string requestex);

In the Service file

public CadastrodeEscolasResponse TabelasAuxiliares(string requestex)
        {

            XmlSerializer serializer = new XmlSerializer(typeof(CadastrodeEscolasRequest));
            StringReader rdr = new StringReader(requestex);
            CadastrodeEscolasRequest request = (CadastrodeEscolasRequest)serializer.Deserialize(rdr);
}

Conslusion: Call the service by sending Xml format data to a string parameter. Then convert the xml to the required class object. This way you can avoid creating QueryStringConvertor which is quite cumbersome. Hope this will help! This help is for all and not just for this post.

Using WCF webHttp binding, is it possible to pass arbitrary query , Once the interface is defined, we can implement the interface and add code to the method. sumA() As Integer) As Integer Implements WCFRestful. In order to use a custom QueryStringConverter, we would have to create a  Coming back to “proper” WCF extensibility, this week’s post is about the QueryStringConverter. This is actually a simple topic to be covered, as its purpose is quite specific (unlike other extensibility points seen before, which could be used for a wide variety of cases) – within WCF the QueryStringConverter is only used on endpoints which have the WebHttpBehavior applied to them.

WCF: How to pass a variable number of parameters to a WebGet , I've implemented a customized QueryStringConverter class and hooked it up using a How can I implement a custom QueryStringConverter for RESTful WCF​? I've read what you mean in the answer to the question you're creating a possible duplicate of: How to have optional parameters in WCF REST service? You can get the desired effect by omitting the Query string from the UriTemplate on your WebGet or WebInvoke attribute, and using WebOperationContext.Current.IncomingRequest.UriTemplateMatch

How to create a RESTful service in WCF, WCF makes it very easy to expose JSON data over a RESTful interface, as long For this example we are returning a custom type of Person. For SOAP , basicHttpBinding would be used and for REST webHttpBinding would be used; Both SOAP and REST will have same base address ; Note : I have taken different Service Contract for REST and SOAP. However you can have it on same ServiceContract also. Create Service. Let us create two service contracts . One for SOAP and one for REST Service.

In the WCF web programming model, how can one write an , Using WCF webHttp binding, is it possible to pass arbitrary query string arguments? first step of your implementation, this will work: public string GetData(string value) You can write a custom QueryStringConverter which receives all your query and my beans.xml where I have registered the handler and restful service:  We can also implement a custom PrincipalPermission attribute to control the granularity of authorization. Note: We can also create an Authentication service to validate the user name password and create an authentication cookie after validation. Here, the assumption is that WCF REST is hosted with the Web application and therefore shares the context.

Comments
  • UPDATE: This has been fixed in .Net 4.5