java - What is the best practice for sharing models between a WEB API server and an Android client application -


i have android application talks .net server using web api web services. currently, have transfer objects on server , on client.

java class

public class useraction {      private string username;     private string action;      public string getusername() {         return username;     }      public void setusername(string username) {         this.username = username;     }      public string getaction() {         return action;     }      public void setaction(string action) {         this.action = action;     } } 

my c# class on server side

  public class useractionto   {     public string username { get; set; }     public string action { get; set; }   } 

i wish share these models, between 2 applications.

i found question discussing sharing types situation bit different. should share types between web api service , client ? other options?

i considering creating c++ dll, both android application , c# application use. best option?

edit using json transfer data

the best option use standard platform-neutral format (usually either json or xml). gives immense freedom vary both client , server way wish , makes development , testing easier, since can inspect or generate content easily.

if you're asking easy mechanism representing content in-memory on multiple endpoints, it's reasonable create "client sdk" (many online services publish them multiple programming languages each) has these dtos , perhaps utilities , use appropriate 1 server-side. not idea overly clever , drop native code; keep code dtos in appropriate language (such java android, or perhaps c# if using xamarin).


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -