Create a new table ad on the server-side database
In the DATAINFO.EDXM model, click Update model from database, publish.
A new entity ad is created.
Then create a new CS file
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingsystem.web;5 usingSYSTEM.WEB.MVC;6 usingNewtonsoft.json;7 usingNewtonsoft.Json.Linq;8 9 namespacewebjson.controllersTen { One Public classAdshowcontroller:controller A { -Datainfo Storedb =Newdatainfo (); - PublicJarray Index (intAdid) the { -Ienumerable<ad>AD; -AD = storedb.ad.Where (U = u.adid = =adid); - stringAdjson =Jsonconvert.serializeobject (AD); +Jarray Adjarray =Jarray.parse (Adjson); - + returnAdjarray; A at } - } -}View Code
You can then publish the JSON array object that you passed on the web side.
Http://59.78.93.208:9092/AdShow?adid=1
Writing service files on the Android side
1 Public classAdshowservice {2 PublicJsonarray getadshowdetails (String adid)3 {4String url= "http://59.78.93.208:9092/AdShow?adid=" +adid+ "";5HttpClient client =Newdefaulthttpclient ();6Client.getparams (). Setparameter (Coreconnectionpnames.connection_timeout, 3000);7Client.getparams (). Setparameter (Coreconnectionpnames.so_timeout, 3000 );8 HttpPost request;9 Try {TenRequest =NewHttpPost (NewURI (URL)); OneHttpResponse response =Client.execute (request); A if(Response.getstatusline (). Getstatuscode () = = 200) { -httpentity entity =response.getentity (); - if(Entity! =NULL) { theString out =entityutils.tostring (entity); -Jsonarray jsonarray=NewJsonarray (out); - returnJsonarray; - } + } -}Catch(Exception e) { + e.printstacktrace (); A return NULL; at } - return NULL; - } - -}View Code
Android Development Diary (iv)