Karusmeister
Karusmeister

Reputation: 871

Deploying CXF service endpoint with Spring dependency injection

I'm trying to inject spring bean into class annotated with @WebService and @SOAPBinding annnotations.

@WebService(targetNamespace = JAXWSMessageHandler.MY_URL)
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class JAXWSMessageHandler {

    private StorageManager bufferContainer;

    public void setBufferContainer(StorageManager storageManager){
        this.bufferContainer = storageManager;

    }

and I get the following exception:

Service class soap.service.JAXWSMessageHandler method setBufferContainer part {http://myurl/myproject/v1}setBufferContainer cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.

It seems that the operation used by spring is expected to be defined in WSDL by CXF. I think I can hack it with singleton mediator class that would allow communication from WebService class to my business class,however, it doesn't sound good to me and I'd like to do that properly. Any hints how to do that?

Upvotes: 0

Views: 2711

Answers (2)

simonh
simonh

Reputation: 539

I think I have a better solution:

Presumably you are using @WebMethod to annotate the methods you want to expose on your web service?

Well you can also add a @WebMethod annotation to your setter method, and set the attribute 'exclude' to be true. This means that this method will not be expected to be defined in your wsdl.

@WebService(targetNamespace = JAXWSMessageHandler.MY_URL)
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class JAXWSMessageHandler {

private StorageManager bufferContainer;

@WebMethod(exclude=true)
public void setBufferContainer(StorageManager storageManager){
    this.bufferContainer = storageManager;

}

Upvotes: 1

Jonathan W
Jonathan W

Reputation: 3799

JAX-WS is interpreting the method signatures on the annotated class as web service operations. My guess is that if you used constructor injection (instead of setter injection), the problem would go away.

Upvotes: 1

Related Questions