SharePoint 2010 Webservice is alwayes returing XML
-
Friday, May 18, 2012 1:41 PM
I have a custom Sharepoint webservice returning array of obejcts. But when I call this webservice from JQuery it alwayes return XML. When I set contentType as "application/json" the web service throws error saying "Unsupported media type".
I want array of objects back. I have set [ScriptMethod(ResponseFormat = ResponseFormat.Json)] above my webmethod.
One more thing, even if the webservice is getting executed successfully, always AjaxFailed() function is getting executed. The success function is never getting executed.
so two problems
1. How to return JSON ?
2. Why alwayes Ajax failed function is getting executed even if status says OK. ?
Code snippet is below.
Thanks much in advance.
All Replies
-
Friday, May 18, 2012 5:18 PM
Hi!
Did you try to specify content-type in request?
Content-Type: application/jsonMVP Office Development, MCP, MCTS SharePoint 2010 Development
-
Friday, May 18, 2012 5:49 PMModerator
Hi
In the var wsUrl = "_vti_bin/DisclosureWebService.asmx "; line
shouldn't you append the name of your webmethod ?
var wsUrl = "_vti_bin/DisclosureWebService.asmx/<name_of_method> ";
Regards Bjoern
Blog -
Saturday, May 19, 2012 1:26 AM
This link maybe helpful.
http://encosia.com/asmx-scriptservice-mistakes-installation-and-configuration/
Blog | SharePoint Field Notes Dev Tool | ClassMaster
-
Tuesday, May 22, 2012 5:30 PM
Yes I Did. If I specify application/json , the function throws error saying "Unsupported media type."
-
Tuesday, May 22, 2012 5:32 PM
Yes I did add a webmethod name. Also the SOAP request has details. So even if I dont mention the webmethod name, the SOAP request takes care of that.
Madhura
-
Tuesday, May 29, 2012 4:32 PM
I removed the SoapREquest parameter and it started returning the Json object.- Marked As Answer by MKKi Tuesday, May 29, 2012 4:32 PM

