我尝试使用版本化肥皂服务进行一些测试。 我的想法是业务逻辑总是实现最新版本,肥皂服务提供其功能。为了支持旧版本的接口,我想通过映射框架将jaxb类映射到较新版本,然后从旧端点调用端点实现。所以在端点v1中,我注入端点v2并从那里调用它。但似乎cdi和ejb注射都不起作用:
@Stateless
@WebServiceProvider(serviceName = "WebserviceV1", wsdlLocation = "META-INF/wsdl/My.wsdl", targetNamespace = "http://smitch.ch/service/v1", portName = "ServicePortV1")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ServiceImplV1 implements ServicePortV1 {
private ModelMapper modelMapper = new ModelMapper();
@Inject
private ServiceImplV2 v2;
@PostConstruct
void configureMapping() {
PropertyMap<v1.RequestType, v2.RequesType> specialCase = new PropertyMap<>() {
protected void configure() {
//...
}
};
modelMapper.addMappings(specialCase);
}
@Override
public v1.ResponseType service(v1.RequestType soapRequest) {
v2.RequestType v2Request = map(soapRequest, v2.RequestType.class);
return map(v2.service(v2Request), v1.ResponseResponse.class);
}
}
版本2端点的定义方式大致相同,但已在实体中实现了业务逻辑。
我总是收到错误
WELD-001408 Unsatisfied dependencies for type [ServiceImplV2] with qualifiers [@Default] at injection point [[field] @Inject private v1.ServiceImplV1.v2]"}}
我使用JBoss EAP 6.3。 在处理Web服务端点时是否存在一些特殊行为?
这里有更多信息。这两个类都在同一个包中,是的,我有一个beans.xml。
V2看起来像:
@Stateless
@WebServiceProvider(serviceName = "WebserviceV2", wsdlLocation = "META-INF/wsdl/MyV2.wsdl", targetNamespace = "http://smitch.ch/service/v2", portName = "ServicePortV2")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ServiceImplV2 implements ServicePortV2 {
@Inject
private Processor processor;
@Override
public v2.ResponseType service(v2.RequestType soapRequest) {
return processor.process(soapRequest);
}
答案 0 :(得分:0)
正如Jan所提到的,尝试将@LocalBean添加到ServiceImpleV2以添加无界面视图。然后,您应该能够使用@EJB或@Inject来管理您的Web服务。
@Stateless
@LocalBean
@WebServiceProvider(serviceName = "WebserviceV2", wsdlLocation = "META-INF/wsdl/MyV2.wsdl", targetNamespace = "http://smitch.ch/service/v2", portName = "ServicePortV2")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ServiceImplV2 implements ServicePortV2 {
@Inject
private Processor processor;
@Override
public v2.ResponseType service(v2.RequestType soapRequest) {
return processor.process(soapRequest);
}