PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, May 19, 2022

[FIXED] How to upload multiple files using webservice with java?

 May 19, 2022     java, web-services, wsdl     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing