Forum Discussion
@WebService
@SOAPBinding(style = Style.DOCUMENT)
public interface ImageServerSwa {
Path PATH_UPLOAD = Paths.get("/", "home", "ankur", "soap", "kotak.jpg");
Path PATH_DOWNLOAD = Paths.get("/", "home", "ankur", "Pictures", "kotak.jpg");
//download a image from server
@WebMethod
@XmlAttachmentRef
DataHandler downloadDataHandler();
@WebMethod
void uploadDataHandler(@XmlAttachmentRef DataHandler dataHandler);
}
@WebService(endpointInterface = "com.github.ankurpathak.soap.ImageServerSwa")
public class ImageServerSwaImpl implements ImageServerSwa {
@Override
@XmlAttachmentRef
public DataHandler downloadDataHandler() {
File file = PATH_DOWNLOAD.toFile();
FileDataSource dataSource = new FileDataSource(file);
DataHandler dataHandler = new DataHandler(dataSource);
return dataHandler;
}
@Override
public void uploadDataHandler(@XmlAttachmentRef DataHandler data) {
if (data != null) {
File file = PATH_UPLOAD.toFile();
try {
FileUtils.copyInputStreamToFile(data.getInputStream(), file);
} catch (IOException ex) {
throw new WebServiceException();
}
}
}
}
Related Content
- 2 years ago
- 2 years ago
Recent Discussions
- 2 days ago