mail@pastecode.io avatar
7 months ago
2.0 kB
This error typically occurs when Spring cannot find a bean of type `org.springframework.ws.client.core.WebServiceTemplate` to inject into your `SoapServiceImpl` class.

Let's ensure that your configuration is correctly defining the `WebServiceTemplate` bean. Update your `SoapConfig` class to explicitly define the `WebServiceTemplate` bean:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.ws.client.core.WebServiceTemplate;

public class SoapConfig {

    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        return marshaller;

    public WebServiceTemplate webServiceTemplate(Jaxb2Marshaller marshaller) {
        WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
        return webServiceTemplate;

Ensure that you have the correct package name (`com.example.generated`) in the `setContextPath` method according to the package where your JAXB classes are generated.

Make sure that your `SoapServiceImpl` class is in a package that is scanned by Spring component scanning. If the classes are not in the same package or a subpackage, you might need to explicitly specify the package to scan in your `@SpringBootApplication` annotation.

For example:

@SpringBootApplication(scanBasePackages = "com.example")
public class YourApplication {
    public static void main(String[] args) {
        SpringApplication.run(YourApplication.class, args);

Make these adjustments and try running your application again. If the issue persists, there might be additional details in the error message or the logs that could help diagnose the problem.
Leave a Comment