Can a web service return a stream?

前端 未结 12 1731
眼角桃花
眼角桃花 2021-02-02 09:23

I\'ve been writing a little application that will let people upload & download files to me. I\'ve added a web service to this applciation to provide the upload/download fun

12条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 10:06

    Yes, it is possible with Metro. See the Large Attachments example, which looks like it does what you want.

    JAX-WS RI provides support for sending and receiving large attachments in a streaming fashion.

    • Use MTOM and DataHandler in the programming model.
    • Cast the DataHandler to StreamingDataHandler and use its methods.
    • Make sure you call StreamingDataHandler.close() and also close the StreamingDataHandler.readOnce() stream.
    • Enable HTTP chunking on the client-side.

提交回复
热议问题