Asynchronous web service SOAP

梦想的初衷 提交于 2019-12-20 02:31:37

问题


I have an interface that I've exposed as a regular SOAP web service. One method of the interface consists for the client to send a file to the server, then the server processes the file and returns a result file. Processing the file may take some time, so I think using asynchronous invocation of this method is a better idea. I thought about the following flow:

The client invokes the asynchronous method and sends the file using an attachment (MTOM). When the file is received by the server, a response is sent back to the client indicating that the file has been received and that it will be processed shortly. Once the file is processes, a response is sent back to the client indicating it has been processed and a result file is returned in the response also as an attachment.

Is it possible using SOAP with CXF?

Thanks


回答1:


You can use Callback approach of Asynchronous InvocationModel.

Callback approach - in this case, to invoke the remote operation, you call another special method that takes a reference to a callback object (of javax.xml.ws.AsyncHandler type) as one of its parameters. Whenever the response message arrives at the client, the CXF runtime calls back on the AsyncHandler object to give it the contents of the response message

More information can be had from the following:

Apache CXF




回答2:


If you use some tool like WSDL2Java for client generation, you can even choose to generate an asynchronous client. It will generate for you a callback handler with empty methods for each of the service operations and exceptions of the service. You then can just implement those methods to set the actions to do when the response is received. Remember that when an asynchronous call is done a new thread is started.




回答3:


Yes, Once you receive the file, you may return the request id to client and start processing on server side and do maintain various states of processing. Client can come back in different interval, and will receive the processing status or the output if it is completed.



来源:https://stackoverflow.com/questions/10877223/asynchronous-web-service-soap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!