Apache Camel CXF gives you “org.apache.cxf.service.factory.ServiceConstructionException: Could not find portType named {<some namespace>}<some service>PortType”

I got this when implementing a SOAP service from a provided wsdl. I hope I would not done the same mistake if I wrote the wsdl myself, but we will never know for sure 😉

Now to the solution. You probably have something like this in your code (Apache Camel in a SpringBoot application)

...
@Component
public class CurrencyRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("cxf:bean:currencyLookupAdapterEndpoint")
            .log("Body: ${body}");
    }

    @Bean
    private CxfEndpoint currencyLookupAdapterEndpoint() {
        final CxfEndpoint cxfEndpoint = new CxfEndpoint();
        cxfEndpoint.setWsdlURL("currencies.wsdl");
        cxfEndpoint.setAddress("/getCurrencies");

        // Set the Service Class
        cxfEndpoint.setServiceClass(CurrenciesResponderService.class);

        cxfEndpoint.setProperties(new HashMap<>());
        cxfEndpoint.getProperties().put("schema-validation-enabled", "true");
        return cxfEndpoint;
    }
}

In the currencies.wsdl I had a CurrenciesResponderService and a CurrenciesResponderInterface.
If I choose the CurrenciesResponderService.class as the ServiceClass I got the error below:

org.apache.cxf.service.factory.ServiceConstructionException: Could not find portType named {<some namespace>}<some service>PortType

and if I choose the CurrenciesResponderInterface.class instead the application started without the error 🙂

Tested on Apache Camel v3.17 and SpringBoot v3.2.0

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.