locked
WebService returns XML even when ResponseFormat set to JSON RRS feed

  • Question

  • User265119340 posted

    Hello,

    I have created a simple web service and method that returns 'Hello World', but I want the method to return the string as json. I have set ResponseFormat = ResponseFormat.Json and on the client I have set the request content type to "application/json; charset=utf-8". Still, the response is always xml. Any thoughts about what i need to change to get a json response. I am using Prototype.js to handle all the ajax stuff. I have verified that the request object does have the correct content type and that the response object does have null for responseJSON and null for headerJSON.

    aspnet 3.5, windows server 2008, IIS 7, vb.net

    Thank you.

    (relevant code)

    <WebService(Namespace:="http://tempuri.org/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <
    Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    <ScriptService()> _
    Public Class Locations Inherits System.Web.Services.WebService

    <Script.Services.ScriptMethod(ResponseFormat:=System.Web.Script.Services.ResponseFormat.Json, UseHttpGet:=True, XmlSerializeString:=False)> _
      <WebMethod()> _

    Public Function HelloWorld() As String

    Return "Hello World"

    End Function

     

    Monday, September 29, 2008 3:31 PM

Answers

All replies