Issue
Well, I've searched here about how to make upload files using webservice on java, but without any satisfactory answer. I need to build a method where i recevie some Strings, and a list of files. Someone can give me a direction about how to create that webservice where i can upload multiple files?
@WebMethod()
public String criarPA(String name, List<File> files)
Its something like this... I've already seen that i cant use File... So what can i use instead of?
Solution
You cannot use File because SOAP protocol used in WebService doesn't have such type. But you can always send array of bytes:
@XmlType
public class SoapFile implements Serializable {
private String fileName;
private byte[] fileData;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public byte[] getFileData() {
return fileData;
}
public void setFileData(byte[] fileData) {
this.fileData = fileData;
}
}
And now your code will look something like this:
@WebMethod
public String criarPA(List<SoapFile> files)
Next you just have to create File
from byte array saved in SoapFile
with standard "Java" way.
Answered By - Michał Kupisiński Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.