开发者

Serve static files with jax.ws

I'开发者_运维问答m building a web front end to monitor the state of a SOAP service.

Is there any way to serve static files with jax.ws? For example Endpoint.publish("/static", new SomeStaticFileHandler()) where any requests to /static just serve the corresponding static file in my folder? Inside the static file I would like to query the state and update the page with AJAX calls.

Thanks!


The correct way to serve static files is to add a custom servlet to the web.xml.

As for the hack you want to try: serve any file type, with any content-type? It will not work, I believe. Perhaps you can serve XML files if they follow a predefined schema -- JAX-WS implementation classes return objects, not strings or streams. These objects are serialized to SOAP/XML using the schema and binding. You'd need to parse the files into objects and then return to JAX-WS runtime... and you'll get a SOAP envelope over the file content anyway.

Inside the static file I would like to query the state and update the page with AJAX calls

This doesn't sound like a static file to me. This is a dynamic method serving XML or JSON. The simplest answer is still a servlet.

JAX-RS (RESTful Java API) is a viable alternative too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜