开发者

JSON From ASMX Service

I'm trying to get a VB.NET ASMX web service to ret开发者_开发技巧urn 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.


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


Use attribute ScriptService on your web-service class.


Try putting <ScriptService> attribute on the class.


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

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

and immediately above the remaining code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜