Lots of frameworks let me expose an ejb as a webservice.
很多框架让我将ejb作为web服务公开。
But then 2 months after publishing the initial service I need to change the ejb or any part of its interface. I still have clients that need to access the old interface, so I obviously need to have 2 webservices with different signatures.
但是在发布初始服务后2个月,我需要更改ejb或其界面的任何部分。我仍然有需要访问旧界面的客户端,所以我显然需要2个具有不同签名的web服务。
Anyone have any suggestions on how I can do this, preferably letting the framework do the grunt work of creating wrappers and copying logic (unless there's an even smarter way).
任何人都对我如何做到这一点有任何建议,最好让框架做创建包装和复制逻辑的繁琐工作(除非有更聪明的方法)。
I can choose webservice framework on basis of this, so suggestions are welcome.
我可以在此基础上选择webservice框架,欢迎提出建议。
Edit: I know my change is going to break compatibility,and I am fully aware that I will need two services with different namespaces at the same time. But how can I do it in a simple manner ?
编辑:我知道我的更改将破坏兼容性,我完全意识到我将需要同时具有不同命名空间的两个服务。但是我怎么能以简单的方式做到这一点呢?
3 个解决方案
#1
5
I don't think, you need any additional frameworks to do this. Java EE lets you directly expose the EJB as a web service (since EJB 2.1; see example for J2EE 1.4), but with EE 5 it's even simpler:
我不认为,你需要任何额外的框架来做到这一点。 Java EE允许您直接将EJB公开为Web服务(从EJB 2.1开始;参见J2EE 1.4的示例),但使用EE 5它甚至更简单:
@WebService
@SOAPBinding(style = Style.RPC)
public interface ILegacyService extends IOtherLegacyService {
// the interface methods
...
}
@Stateless
@Local(ILegacyService.class)
@WebService(endpointInterface = "...ILegacyService", ...)
public class LegacyServiceImpl implements ILegacyService {
// implementation of ILegacyService
}
Depending on your application server, you should be able to provide ILegacyService
at any location that fits. As jezell said, you should try to put changes that do not change the contract directly into this interface. If you have additional changes, you may just provide another implementation with a different interface. Common logic can be pulled up into a superclass of LegacyServiceImpl
.
根据您的应用程序服务器,您应该能够在任何适合的位置提供ILegacyService。正如jezell所说,您应该尝试将不会将合同直接更改的更改直接放入此界面。如果您有其他更改,您可能只是提供另一个具有不同接口的实现。可以将公共逻辑上拉到LegacyServiceImpl的超类中。
#2
0
I'm not an EBJ guy, but I can tell you how this is generally handled in the web service world. If you have a non-breaking change to the contract (for instance, adding a property that is optional), then you can simply update the contract and consumers should be fine.
我不是EBJ的人,但我可以告诉你这是如何在Web服务世界中处理的。如果您对合同进行了不间断的更改(例如,添加可选的属性),那么您只需更新合同即可,消费者应该没问题。
If you have a breaking change to a contract, then the way to handle it is to create a new service with a new namespace for it's types. For instance, if your first service had a namespace of:
如果您对合同进行了重大更改,那么处理它的方法是创建一个新服务,并为其类型创建一个新的命名空间。例如,如果您的第一个服务具有以下命名空间:
Your new one might have:
你的新人可能有:
Expose this contract to new consumers.
将此合同公开给新的消费者。
How you handle the old contract is up to you. You might direct all the requests to an old server and let clients choose when to upgrade to the new servers. If you can use some amount of logic to upgrade the requests to the format that the new service expects, then you can rip out the old service's logic and replace it with calls to the new. Or, you might just deprecate it all together and fail all calls to the old service.
你如何处理旧合同取决于你。您可以将所有请求定向到旧服务器,并让客户端选择何时升级到新服务器。如果您可以使用一定数量的逻辑将请求升级到新服务所期望的格式,那么您可以删除旧服务的逻辑并将其替换为对新服务的调用。或者,您可能只是将它们全部弃用,并且无法调用旧服务。
PS: This is much easier to handle if you create message class objects rather than reusing domain entities.
PS:如果您创建消息类对象而不是重用域实体,这将更容易处理。
#3
0
Ok here goes;
好的,这里;
it seems like dozer.sourceforge.net is an acceptable starting-point for doing the grunt work of copying data between two parallel structures. I suppose a lot of web frameworks can generate client proxies that can be re-used in a server context to maintain compatibility.
看起来dozer.sourceforge.net是一个可以接受的起点,可以在两个并行结构之间进行复制数据的繁琐工作。我想很多Web框架都可以生成可以在服务器上下文中重用的客户端代理,以保持兼容性。
#1
5
I don't think, you need any additional frameworks to do this. Java EE lets you directly expose the EJB as a web service (since EJB 2.1; see example for J2EE 1.4), but with EE 5 it's even simpler:
我不认为,你需要任何额外的框架来做到这一点。 Java EE允许您直接将EJB公开为Web服务(从EJB 2.1开始;参见J2EE 1.4的示例),但使用EE 5它甚至更简单:
@WebService
@SOAPBinding(style = Style.RPC)
public interface ILegacyService extends IOtherLegacyService {
// the interface methods
...
}
@Stateless
@Local(ILegacyService.class)
@WebService(endpointInterface = "...ILegacyService", ...)
public class LegacyServiceImpl implements ILegacyService {
// implementation of ILegacyService
}
Depending on your application server, you should be able to provide ILegacyService
at any location that fits. As jezell said, you should try to put changes that do not change the contract directly into this interface. If you have additional changes, you may just provide another implementation with a different interface. Common logic can be pulled up into a superclass of LegacyServiceImpl
.
根据您的应用程序服务器,您应该能够在任何适合的位置提供ILegacyService。正如jezell所说,您应该尝试将不会将合同直接更改的更改直接放入此界面。如果您有其他更改,您可能只是提供另一个具有不同接口的实现。可以将公共逻辑上拉到LegacyServiceImpl的超类中。
#2
0
I'm not an EBJ guy, but I can tell you how this is generally handled in the web service world. If you have a non-breaking change to the contract (for instance, adding a property that is optional), then you can simply update the contract and consumers should be fine.
我不是EBJ的人,但我可以告诉你这是如何在Web服务世界中处理的。如果您对合同进行了不间断的更改(例如,添加可选的属性),那么您只需更新合同即可,消费者应该没问题。
If you have a breaking change to a contract, then the way to handle it is to create a new service with a new namespace for it's types. For instance, if your first service had a namespace of:
如果您对合同进行了重大更改,那么处理它的方法是创建一个新服务,并为其类型创建一个新的命名空间。例如,如果您的第一个服务具有以下命名空间:
Your new one might have:
你的新人可能有:
Expose this contract to new consumers.
将此合同公开给新的消费者。
How you handle the old contract is up to you. You might direct all the requests to an old server and let clients choose when to upgrade to the new servers. If you can use some amount of logic to upgrade the requests to the format that the new service expects, then you can rip out the old service's logic and replace it with calls to the new. Or, you might just deprecate it all together and fail all calls to the old service.
你如何处理旧合同取决于你。您可以将所有请求定向到旧服务器,并让客户端选择何时升级到新服务器。如果您可以使用一定数量的逻辑将请求升级到新服务所期望的格式,那么您可以删除旧服务的逻辑并将其替换为对新服务的调用。或者,您可能只是将它们全部弃用,并且无法调用旧服务。
PS: This is much easier to handle if you create message class objects rather than reusing domain entities.
PS:如果您创建消息类对象而不是重用域实体,这将更容易处理。
#3
0
Ok here goes;
好的,这里;
it seems like dozer.sourceforge.net is an acceptable starting-point for doing the grunt work of copying data between two parallel structures. I suppose a lot of web frameworks can generate client proxies that can be re-used in a server context to maintain compatibility.
看起来dozer.sourceforge.net是一个可以接受的起点,可以在两个并行结构之间进行复制数据的繁琐工作。我想很多Web框架都可以生成可以在服务器上下文中重用的客户端代理,以保持兼容性。