This is an XFire plugin for Grails. This plugin allows you to expose Web services using Grails' service classes.Main contributor: Chanwit Kaewkasi (chanwit At gmail Dot com)Latest plugin version is 0.8.1.or if you have a plugin archive locally.
You will get "TestService.groovy" in your service directory.
Then, declare the static property "expose" and you may have some methods like:
You may declare some method like:
In the above example WebParam is the standard javax.jws.WebParam annotation. In order to use this you will need groovy 1.1 or later and to add an import statement at the top of the source file.After running the command "grails run-app",
you can access the WSDL of this example fromhttp://127.0.0.1:8080/your_grails_app/services/test?wsdlPlease note that TestService.groovy becomes 'test' in WSDL.Remark
Example of avoiding circular references:
Installation
Type this command in your Grail application directory$> grails install-plugin xfire
$> grails install-plugin /path/to/grails-xfire-0.8.1.zip
Dependencies
This snapshot includes some dependency jar file. If it cannot run out-of-the box, please report in the Grails user group.Getting Started
This plugin detects the static property 'expose' of a service class. If the 'expose' property contains 'xfire' keyword, then the plugin exposes the service as a Web service.For example, type this:$> grails create-service Test
class TestService { static expose=['xfire'] boolean serviceMethod(YourDomainClass dc){
return true;
} MyPOGO otherServiceMethod(@WebParam(name="token", header=true)UserToken token,
MyOtherPOGO obj) {
// do something here
}}- Do not use def as returntypes of methods: it will generate xsd:anyType in the WSDL - specify your return type!
- To avoid circular referencing, which may cause stack overflow, you have to specify the following in your domain classes (as of version 0.8.1):
static xmlTransients = ['<property name>',...]class Author { static hasMany = [books: Book] String name
}class Book { static xmlTransients = ['author'] String name
Author author
}Upgrade to Grails 1.0.4
Content Negotiation for xml has to be switched off by removing the "xml" mime-type mapping from the grails.mime.types configuration option in Config.groovy. See http://jira.codehaus.org/browse/GRAILS-3537Upgrade to Grails 0.6
The name of the plugin has changed from the earlier version to 0.6.1 from XFire to Xfire. Grails gets confused by that, so simply installing the new version is not sufficient, you also have to delete the previous version manually from ./pluginsUpgrade to Grails 0.5(URL Mapping)
It starts to use URL mapping since grails 0.5, the grails project's XxxUrlMapping.groovy and the URL mappings of plug-ins, that provide their own mapping, has to be modified as below:static mappings = { "/$controller/$action?/$id?"{ constraints { controller(matches:/(?!services).+|services.+/) } } }
Version History
v. 0.8.1- added detection of 'static xmlTransients' in Domain classes to exclude association properties that may cause circular referencing.
- fixed jar linkage conflicts.
- upgraded for Grails 1.1
- fixed POGO containing generic fields
- tested against Grails 1.0
- GRAILSPLUGINS-222 - Regenerate XfireGrailsPlugin*.class when service class is modified
- GRAILSPLUGINS-229 - Reloading when name or namespace of the service class is changed
- GRAILSPLUGINS-232 - Exceptions thrown by xfire service methods always returned as java.lang.reflect.UndeclaredThrowableException
- GRAILSPLUGINS-217 - Support Generics
- GRAILSPLUGINS-219 - Allow to customize generated targetNamespace via @WebService
- minor bugs fixed
- tested against Grails 1.0-RC4
- tested against Grails 0.6
- tested against Grails 0.5.6
- support the WebParam annotation via Groovy 1.1
- added POGO serialization support (beside Grails domain classes)
- updated to use the new Artefact API
- tested against Grails 0.5
- updated XFire to 1.2.6
- test against Grails 0.4
- fixed detection of the transactional property (again)
- improved skipping of all "Groovy" properties
- skipped a java.lang.Boolean property (with "get" prefix !)
- changed convention (using "static expose=['xfire']" instead of the "XFireService" suffix)
- changed URI (now it's http://127.0.0.1:8080/app/services/test?wsdl for "TestService.groovy")
- the jar name is going to be SNAPSHOT until Grails 0.4 released.
- updated XFire to 1.2.4
- fixed detection of the transactional property
- fixed detection of "metaMethods"
- refactored
- added support for Grails domain classes
- changed the version number to be compatible with Grails
- first public release
- initial


1 Comment
Post a Comment
Site Login