动态定义的 webmethod 参数
简短的介绍。有一个生产系统,其中一些独立的客户端“发明”了一些具有某些属性和行为的对象 - 人们可以为这些对象分配一些值,将它们启动到操作中并在执行时/同时读取它们的状态。 一切都通过 Web 界面进行:客户端登录、分配值、注入对象、启动容器并查看其对象发生变化。
一切都基于客户端的 JAXB 兼容模式。 Schema 被编译成 Java 类并打包为客户端的 jar。 (非常感谢 stackoverflow 成员帮助我即时完成此操作)。
问题是:他们希望 Web 服务 (SOAP) 通过 Web 界面完成目前所做的所有工作。当然,使用根据 JAXB 模式的 wsdl 类型,它们每天都会动态更改和部署:( 实际上,他们通过 Web 执行的所有操作都是:
- 启动/停止应用程序容器(常见任务,不是问题)
- 将客户端定义的对象注入到容器中
- 从容器“3”中检索特定类型的对象
一旦“2”成为问题好的。但“2”让我发疯,在我开始做某事之前我需要你的建议。就 WebService 而言,我的问题是:假设参数类型是由客户端的 JAXB 架构定义的,如何使用以下方法发布 WS 端点:
@WebMethod
public void inject(UserDefinedObject obj) {
getAppContainer().inject(obj); // that's all I have to implement
}
以下是我正在考虑的方法:
使用对象作为参数:
public voidject(Object obj);
和代码ServletFilter
根据客户端架构修改 xml 请求/响应。但我不确定 WS servlet 在这种情况下不会检查方法签名并抛出异常。另一个问题是我是否可以从该方法中访问请求的 xml 来执行 JAXB 解组。由于我已经在编译客户端 jar,因此我还可以编译 Web 服务端点并将它们动态部署为 OSGI 包。我对 OSGI 完全陌生,这里有太多问题:这是否可能,我的耳朵怎么样,我是否需要将所有内容都作为 OSGI,如何与 EJB 通信,等等。
更多谷歌搜索,但是我担心布林和佩奇将开始向我收费。
还有其他想法吗?
Short introduction. There is a production system where some independent clients "invent" some objects with some properties and behavior - one can assign some values to these objects, launch them into action and read their state upon/while execution.
Everything's via web interface: client logs in, assigns values, injects objects, launches container and sees his objects mutating.
Everything is based on client's JAXB-compliant schema. Schema is compiled into Java classes and packaged as client's jar. (Many thanks to stackoverflow members who helped me to do it on the fly).
And here is the problem: they want webservice (SOAP) doing all they currently do via web-interface. And, of course, with wsdl types according to JAXB schema they dynamically change and deploy on the daily basis :(
Actually, all the operations they do via web are:
- Start/stop application container (common task, not a problem)
- Inject client-defined object into container
- Retrieve objects of specific type from container
"3" is not an issue once "2" is ok. But "2" is driving me mad and I need your advice BEFORE I start doing something. In terms of WebService my question is: How do I publish WS endpoint with following method, assuming that argument type is defined by client's JAXB schema:
@WebMethod
public void inject(UserDefinedObject obj) {
getAppContainer().inject(obj); // that's all I have to implement
}
Here are approaches I'm thinking of:
Use Object as argument:
public void inject(Object obj);
and codeServletFilter
to modify xml request/response according to client's schema. But I'm not sure WS servlet will not check method signature and throw exceptions in that case. Another question is whether I will have access to request's xml from within that method to perform JAXB unmarshalling.As I'm already compiling client jars, I could also compile webservice endpoints and deploy them dynamically as OSGI bundles. I'm absolutely new to OSGI, too many questions here: is it possible at all, what about my ear, do I need to make all as OSGI, how to communicate with EJB, etc, etc.
More googling, but I'm afraid Brin & Page will start charging me.
Any other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后决定支持 OSGi 选项,如 正确方法的解决方案中所述将 EAR 模块转换为 OSGi 包。一旦我的管理战争被拉出耳朵,变成 OSGi 捆绑包并因此获得对 BundleContext 的访问权限,就可以动态部署/取消部署客户端的个人 Web 服务:
不确定此解决方案是否适用于其他基于非 OSGi 的应用程序服务器。我想需要一些额外的 OSGI 配置才能使其与 EAR 的其余部分交互顺利工作。
Finally decided in favour of OSGi option as described in solution to correct way to turn EAR module into OSGi bundle. Once my admin war was pulled out of ear, turned into OSGi bundle and therefore gained access to BundleContext, it's is possible to dynamically deploy/undeploy client's personal webservics on the fly:
Not sure this solution is applicable to other, non-OSGi based app servers. I suppose some extra OSGI configuration will be required to make it work smoothly in interaction with remaining part of EAR.