2016-07-08 7 views
-2

Es gibt eine Produktklasse. Eine Liste von Objekten der Produktklasse wird gebildet und diese Liste wird in ein Objekt der Bestellklasse eingekapselt. Beide Klassen sind unten angegeben.So senden Sie ein Objekt innerhalb eines Objekts von Mobile-Anwendung an einen PHP-Web-Service mit Volley-Bibliothek

Product.java

package com.example.gandhjee.pantry_order; 

import java.io.Serializable; 

public class Product implements Serializable{ 
    private int id; 
    private String name; 
    private int amount; 
    private int final_id; 
    private int price; 
    private int price_per_plate; 
    //private String description; 
    private static final long serialVersionUID = -5435670920302756945L; 

    //Constructor 

    public Product(int final_id,int id, String name, int amount , int price ,int price_per_plate) { 
     this.id = id; 
     this.name = name; 
     this.amount = amount; 
     this.setName(name); 
     this.setAmount(amount); 
     this.setFinal_id(final_id); 
     this.price_per_plate = price_per_plate; 
     this.final_id = final_id; 
     this.price = price; 
    } 

    public int getPrice_per_plate(){ 
     return price_per_plate; 
    } 

    public int getPrice(){ 
     return price; 
    } 

    public void setPrice(int price){ 
     this.price = price; 
    } 

    public void setFinal_id(int final_id){ 
     this.final_id=final_id; 
    } 

    public int getFinal_id(){ 
     return final_id; 
    } 

    public int getId(){ 
     return id; 
    } 

    public void setId(int id){ 
     this.id = id; 
    } 

    public String getName(){ 
     return name; 
    } 

    public void setName(String name){ 
     this.name = name; 
    } 

    public int getAmount(){ 
     return amount; 
    } 

    public void setAmount(int amount){ 
     this.amount = amount; 
    } 


} 

Order.java

package com.example.gandhjee.pantry_order; 
import java.io.Serializable; 
import java.util.List; 

public class Order implements Serializable{ 
    private int order_id; 
    private List<Product> mProductList; 
    private String emp_name; 
    private int area_id; 
    private int emp_id; 
    private int conf_room_id; 
    private int type_id; 

    //private String description; 
    private static final long serialVersionUID = -5435670920302756945L; 

    public Order(List<Product> mProductList, int order_id,int emp_id, String emp_name, int type_id , int area_id ,int conf_room_id){ 
     this.mProductList = mProductList; 
     this.order_id = order_id; 
     this.emp_name = emp_name; 
     this.emp_id = emp_id; 
     this.setType_id(type_id); 
     this.setconf_room_id(conf_room_id); 
     this.setArea_id(area_id); 
    } 

    public void setmProductList(List<Product> mProductList){ 
    this.mProductList = mProductList; 
} 
    public Product getmProductList(){ 
     return (Product) mProductList; 
    } 

    public int getConf_room_id(){ 
     return conf_room_id; 
    } 

    public void setconf_room_id(int conf_room_id){ 
     this.conf_room_id = conf_room_id; 
    } 

    public int getArea_id(){ 
     return area_id; 
    } 

    public void setArea_id(int area_id){ 
     this.area_id = area_id; 
    } 

    public void setType_id(int type_id){ 
     this.type_id=type_id; 
    } 

    public int getType_id(){ 
     return type_id; 
    } 

    public int getOrder_id(){ 
     return order_id; 
    } 

    public String getEmp_name(){ 
     return emp_name; 
    } 

    public void setEmp_name(String emp_name){ 
     this.emp_name = emp_name; 
    } 

    public int getEmp_id(){ 
     return emp_id; 
    } 

    public void setEmp_id(int emp_id){ 
     this.emp_id = emp_id; 
    } 

} 

Jetzt möchte ich ein Objekt der Klasse Auftrag von meinem mobilen Anwendung auf einen Web-Service in PHP Volley-Bibliothek senden. Ich habe viel im Internet gesucht, aber es gibt kein Beispiel für das Senden eines Objekts innerhalb eines Objekts von einer mobilen Anwendung an einen Webdienst. Jede Hilfe wäre willkommen. Vielen Dank im Voraus!

+1

Es läuft alles auf, was die Web-Service ist bereit, zu akzeptieren. – apokryfos

+0

Erstellen Sie ein JSON-Objekt aus und senden Sie das JSON – user6547359

+0

Wie erstellen Sie ein JSON-Objekt aus einer Java-Objektliste innerhalb eines Java-Objekts? @ user6547359 –

Antwort