CXF Method Not Found When Further Annotated

When using CXF and the JAXWS annotations to publish web services, like this:

@WebService(targetNamespace = "http://blah")
public class ClientData {
  @WebMethod
  public String getSomething() {
    return something;
  }
}

you can experience problems if you annotate the web service methods with something that spring-aop needs to process. Like when using perf4js nice @Profiled aspect, like this:

@WebService(targetNamespace = "http://blah")
@Profiled
public class ClientData {
  @WebMethod
  public String getSomething() {
    return something;
  }
}

This is due to the fact, that spring will produce a proxy of the @Profiled bean, a proxy that will not have the annotations of the proxied bean. In turn, this will hide the annotations from CXF, which can come out and complain about missing methods on the server side. Like this:

org.apache.cxf.interceptor.Fault: Message part {http://blah}getSomething was not recognized. (Does it exist in service WSDL?)

Solution?

Add the implementorClass attribute on the JAXWS endpoint definitions in your cxf bean definitions xml. This way you tell CXF which class to look for annotations on, instead of just looking on the class of the proxied instance it is passed at runtime.

December 3, 2009 В· polesen В· Comments Closed
Tags: , , , ,  В· Posted in: Programming