File upload in AXIS2 webservice

282 views Asked by At

I'm building a simple web-service to save news with images attached. I already made it as a JSF2 appication which I'm trying to convert to a web-service.

I saw this question's answer Axis2 and Webservices: File Upload but it is about adding a new service which accept DataHanders, is there an easier way to include the file into the news object and send it in one go?

Server side:

- news object

public class Actualite {

    private Part file;
    private String titre;
    private String desc;
    private String image;


    public String getTitre() {return titre;}
    public void setTitre(String titre) {this.titre = titre;}
    public String getDesc() {return desc;}
    public void setDesc(String desc) {this.desc = desc;}
    public String getImage() {return image;}
    public void setImage(String image) {this.image = image;}

    public Part getFile() {return file;}
    public void setFile(Part file) {this.file = file;}

    public String upload(String name) throws IOException, SOAPException {
        // upload
   }
}

- the news service

public class ActualiteDao extends Connexion {
    ..
    public void ajouter(Actualite act) {
        try{
            getDao().create(act);
        } catch (Exception e) {
                e.printStackTrace();
        } finally {
            closeConnection();
        }
    }
    ...
}

Client side: using eclipse i generate the service class ActualiteDaoStub which can be used like this in a controller

ActualiteDaoStub actWS = new ActualiteDaoStub();
Ajouter ajout = new Ajouter();
ajout.setAct(actualite);
actWS.ajouter(ajout);

but this causes an error

org.apache.axis2.AxisFault: Unknow type can not serialize

0

There are 0 answers