Skip to content

WebServiceTemplate(Marshaller marshaller) constructor doesn't call initDefaultStrategies() [SWS-844] #918

@gregturn

Description

@gregturn

Patrick Grimard opened SWS-844 and commented

I noticed this morning that when creating a new WebServiceTemplate using the default no arg constructor, the behaviour is different compared to using the constructor that accepts a Marshaller arg. The constructor with the Marshaller arg doesn't call the initDefaultStrategies() method, and therefore calling methods on the template throws exceptions that you don't get if using the no arg constructor and just call the setMarshaller() and setUnmarshaller() methods.

Here's the 2 constructors source:

public WebServiceTemplate() {
    initDefaultStrategies();
}

public WebServiceTemplate(Marshaller marshaller) {
    Assert.notNull(marshaller, "marshaller must not be null");
    if (!(marshaller instanceof Unmarshaller)) {
        throw new IllegalArgumentException("Marshaller [" + marshaller + "] does not implement the Unmarshaller " +
                "interface. Please set an Unmarshaller explicitly by using the " +
                "WebServiceTemplate(Marshaller, Unmarshaller) constructor.");
    }
    else {
        this.setMarshaller(marshaller);
        this.setUnmarshaller((Unmarshaller) marshaller);
    }
}

Referenced from: commits faaae2d

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions