asp.net - vb.net Webservice with ResponseFormat:=ResponseFormat.Json or ResponseFormat:=ResponseFormat.XML -
my web-application (extjs + asp + vb.net) uses lot of web-services. because of historical grow application uses mix of return-configurations based on xml or json. on client site accept json-response. due more , more complex maintenance i’m trying line web-services 1 standard format, best?
the current 2 configurations have are: xml-formatted response:
<webmethod(enablesession:=true)> _ <scriptmethod(responseformat:=responseformat.xml)> _ public function readrecord(page, start, limit) object 'strjson internally formatted json-string, based on sql-response return "{'d':{'data':[" & strjson & "],'success':true, 'message':'ok'}}" end function json-formatted response:
<webmethod(enablesession:=true)> <scriptmethod(responseformat:=responseformat.json)> public function readrecord (page, start, limit) object dim books list(of clsbook) = new list(of clsbook) 'clsbook class loaded in loop based on sql-response dim book clsbook = new clsbook () book .field1 = “data1” .field2 = “data2” end books.add(book) return new {.data= books, .success=true, .message="ok"} end function the first (xml) configuration simple , gives me lots of flexibility, feels strange client requests json , web-service returns xml in format of json.
the second (json) configuration feels mutch better first 1 because in line request client (json) response have use class (example books) right result, gives me less flexibility. defined each web-service special class , remove classes , return 'json-string' first cofiguration directly sql.
so...:
- which of 2 configurations best or there third option?
- what best way in second configuration format response without need of class?
i hope can me. appreciated.
regards,
arno.
Comments
Post a Comment