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
  • 9,829
  • 30
  • 130
  • 210

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,031
  • 2
  • 23
  • 32
0

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

Mantorok
  • 5,000
  • 2
  • 23
  • 32
0

Use attribute ScriptService on your web-service class.

Sergey Metlov
  • 24,666
  • 27
  • 90
  • 147