简体   繁体   中英

Upload file to webservice (java)

I am looking for a solution to upload a file from a client to a server connected through a web service. The client is written in c# and the web Service in java. The files can be rather large < 100MB.

What approach would you suggest is best ?

Base64 encode the file and send it as an attachment. If you need to make sure the contents of the attachment do not get changed en route, use MTOM. Otherwise, use DIME.

Agree an encoding on both client and server then serialize the file using that encoding, wrap it in CDATA tags and assign the value to a text node in your SOAP request on the client.

Read the data between the CDATA tags on the server, deserialize it using the agreed encoding and you'll have the byte stream to use as need be.

It's probably a good idea for the encoding to involve some sort of compression if the files are large, although be wary of interop issues if the client is .NET and the server Java.

对于服务器端,您应该看看Commons File Upload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM