I have 2 Web service classes that I mean to expose as SOAP services using Apache CXF. One of the services refers to the other as part of its operations. I have set up Apache CXF into my Grails app (no plugins), and set up my Web services through resources.groovy
(Spring Bean DSL).
Say I have the following classes:
@WebService
BookService {
//class definition
}
and:
@WebService
LibraryService {
BookService bookService
//class definition
}
I declare them in my resources.groovy
as follows (namespace declarations omitted):
bookService(BookService)
jaxws.endpoint(id: 'bookService', implementor: "#bookService",
address: '/book')
libraryService(LibraryService) {
bookService = ref('bookService')
}
jaxws.endpoint(id: 'libraryService', implementor: "#libraryService",
address: '/library')
However, every time I run my app (via grails run-app
) I get IllegalAnnotationsException
:
Caused by IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
->> 106 | check in com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder
and I don't understand why its occurring. I'm new to Apache CXF so I hope someone can enlighten me on this.
Update:
I found out that CXF would throw the Exception for any private field I declare inside the service classes unless they are of a type annotated with @XmlRootElement
. This is quite strange.
To work around the issue, what I did was to define a service endpoint interfaces (SEIs), which are pretty much just Java/Groovy interfaces, for my services. I'm not sure if the problem is due to the features added in the background by Groovy, or there really is an issue with the JAX-WS implementation of CXF, or the specifications themselves, but even after converting my services to Java, I still get the errors.
As a result, the LibraryService
in particular now looks like:
@WebService
interface LibraryService {
//class definition
}
and the concrete implementation:
@WebService
class LibraryServiceImpl implements LibraryService {
BookService bookService
//class definition
}
and the bean definition:
libraryService(LibraryServiceImpl) {
bookService = ref('bookService')
}
jaxws.endpoint(id: 'libraryService', implementor: "#libraryService",
address: '/library')