English 中文(简体)
Groovy & Jax-ws: @WebMethod annotation ignored
原标题:

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)

问题回答

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.

According to JAX-WS (JSR-224) specification, if used at type level @SoapBinding annotation specifies the WSDL mapping style for all methods in the class. This include of those that Groovy adds. Moving @SoapBinding to method level should resolve the problem.

Refer to this question: wsimport how to create web service client from WSDL for http:binding GET/POST is the same problem. In your case you have the method setProperty in the class BookService and based on the error, this has more than one parameter. Make sure if you really need this method in your service implementation, if it is so, mark this method as private (in the case that you use this method from your service operation)





相关问题
IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

ASP.net web services

I am using a web service which sets the Thread.CurrentPrincipal object while logging in and soon later when another webmethod of the same web service accesses Thread.CurrentPrincipal, its different/...

Unity Container Disposing and XML Web Service

I am registering some wrapers over un-managed objects in container. How can I dispose of them at the end of the container s lifetime? Please bear in mind I have an XML Web service.

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

热门标签