views:

364

answers:

1

I recently found an example on implementing a We3bService with groovy and jax-ws: the problem is that the @webmethod annotation seems to be ignored.

This is the source code of the groovy script:

import javax.jws.soap.*
import javax.jws.*
import javax.xml.ws.*
import javax.xml.bind.annotation.*

@XmlAccessorType(XmlAccessType.FIELD)
class Book {
    String name
    String author
}
@WebService (targetNamespace="http://predic8.com/groovy-jax/")
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
class BookService{

    @WebMethod
    def add(Book book){
     println "Name of the book: ${book.name}"
    }
}

Endpoint.publish("http://localhost:9000/book", new BookService())

and this is the exception caught: Caught: com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: SEI BookService has method setProperty annotated as BARE but it has more than one parameter bound to body. This is invalid. Please annotate the method with annotation: @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.WRAPPED) at wstest.run(wstest.groovy:21)

A: 

It doesn't ignore your @WebMethod. If it does you wouldn't see any message about 'Bared' and 'Wrapped'.

Try to change def return type with void.

Mykola Golubyev
If a class is annotated just with the @WebService and with non @WebMethod annotation I think that jax-ws try to expose all the methods of the class. If the annotation @WebMethod is present jax-ws tries to expose just the annotated methods. If I am correct the exception thrown is referred to the method "setProperty", wich I think is part of the groovy object implementation.
cerealk