Usually its done via serialization.
For example, by a formal protocol such as SOAP, or by an informal protocol you invent yourself which is understood by both your client and your server.