1

I try to make a little test with versioning a soap service. My idea was that the business logic always implement the newest version and a soap service provide its functionality. To support the older version of the interface I want to map the jaxb classes via mapping framework to the newer version and then call the endpoint implementation from the older endpoint. So in endpoint v1 I inject the endpoint v2 and call it from there. But it seems, that neither cdi nor ejb injection works:

@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);
   }
}

The version 2 endpoint is defined more or less the same way, but has implemented the business logic in the body.

I always get the error

WELD-001408 Unsatisfied dependencies for type [ServiceImplV2] with qualifiers [@Default] at injection point [[field] @Inject private v1.ServiceImplV1.v2]"}}

I use JBoss EAP 6.3. Is there some special behaviour in handling webservice endpoints?

Here some more information. Both classes are in the same package and yes, I have a beans.xml.

V2 looks like:

@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);
    }
boskop
  • 609
  • 5
  • 23
  • Do you have a beans.xml in your META-INF? And if ServiceImplV2 is an EJB, you must inject it with @EJB. The ServiceImplV2 must be in the same EAR(or indicate the correct mappedName) – Jan Piel Mar 04 '15 at 14:31
  • Could show the class and interface of ServiceImplV2 and give information on your application packaging. And no @JanPiel, you don't have to use atEJB to inject an EJB when using CDI (except for remote EJB). – Antoine Sabot-Durand Mar 05 '15 at 03:32
  • Please check the additional information in my original post. – boskop Mar 05 '15 at 06:48
  • Yes, I was wrong with my beans.xml. You should not see an DI-Logging without it, my fault. Another suggestion: Annotate the ServiceImpl with @LocalBean because you want to inject the SLSB directly. – Jan Piel Mar 05 '15 at 07:37

1 Answers1

0

As Jan mentioned, try adding @LocalBean to the ServiceImpleV2 to add a no-interface view. Then you should be able to injet your webservice with @EJB or @Inject.

@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);
    }
rik
  • 156
  • 1
  • 7
  • Hi rik, thanks for your answer. This works perfectly. But could you please explain why? This I don't see. Because with 'normal' beans int not used. – boskop Mar 05 '15 at 08:39
  • Stateless Session Beans are more heavyweight than the DI POJOs(Transaction Management, Webservices and so on). Here http://stackoverflow.com/questions/10889563/ejb-3-1-localbean-vs-no-annotation are some hints. – Jan Piel Mar 05 '15 at 20:41