0
votes

I have a WCF REST Based Service method with URL of two parameters

/GetProduct/{productid}/*{format}

Format expects "xml" to give output in xml and if nothing is provided it returns in JSON. The issue is if enter format as "xml" or any string equal to more than 2 characters, it breaks with an exception "Length cannot be less than zero. Parameter name: length"

If I give just one characters like "x" it works. This is quite strange. Any insights in this.

Operation Contract

[WebGet(ResponseFormat= WebMessageFormat.Json , BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetProduct/{productid}/{*format}")]
Product GetProduct(String productid, String format);

1
Could you provide an example of failing URL?Konrad Kokosa
Fails: <service>/GetProduct/19/xmlNimish
works: <service>/GetProduct/19/x <service>/GetProduct/19/Nimish
I can't reproduce it, how are you hosting this service?Konrad Kokosa
IIS and it is running under full configuration of Sitecore CMS, so that we can utlize the Sitecore Context to get data from it.Nimish

1 Answers

0
votes

If your objective is to get XML or JSON output for the service without any code change. Please have a look at my answer

WCF REST return single method as JSON and XML

Hope that helps.