0

I'm trying to get a VB.NET ASMX web service to return raw JSON (without the .d). I've declared a plethora of attributes but still get XML back. The signature of my method is:

<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, Method:="GET")>
<WebGet(BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=ResponseFormat.Json)>
<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json)>
<WebMethod()>
Public Function TryLogin(ByVal userName As String, ByVal passwordHash As String) As LoginResult

Am I missing a declaration?

EDIT: I've tried requesting via POST, but I still get XML.

Echilon
  • 10,064
  • 33
  • 131
  • 217

4 Answers4

0

Add this line, on its own line, two spaces below your Imports statements:

<System.Web.Script.Services.ScriptService()> _

and immediately above the remaining code.

bommerts
  • 15
  • 3
0

Try putting <ScriptService> attribute on the class.

Cylon Cat
  • 7,111
  • 2
  • 25
  • 33
0

I think your web method needs to return an object type.

Mantorok
  • 5,168
  • 2
  • 24
  • 32
0

Use attribute ScriptService on your web-service class.

Sergey Metlov
  • 25,747
  • 28
  • 93
  • 153