Java Config for Spring Web Service Marshallers - spring-ws

I have been trying to switch from XML configuration to Java configuration for Spring Web Services. The only element I can't seem to do is the marshallers.
The XML line:
annotation-driven marshaller="xmlBeansMarshaller" unmarshaller="xmlBeansMarshaller"
should be replaced with the Java class annotations:
#EnableWs
#Configuration,
but I can't seem to find how to setup the marshallers in code.
Any ideas?
Thanks

Marshallers can just be registered by using a regular #Bean definition. For instance, consider this sample app configuration.

Related

Embedded Jetty web app context/holders serving from two resource bases with one web.xml (spring secuity)

I have an existing application which is using the embedded jetty. Right now jetty has only one WebappContext and serving the files from a directory and also it has web.xml (which has spring security configuration in it)
Now I need to serve some static files using a new war.
What is the easy way to configure existing webappcontext to add a new resource base?
If I add new webappcontext how I can tell jetty to use existing web.xml and spring security?
The serving of static files is just the role of the DefaultServlet
See prior answer about that ...
https://stackoverflow.com/a/20223103/775715
As for the existing web.xml and spring security question, the WebAppContext's are, by design, and by the nature of the servlet spec, isolated from each other.
If you want a single spring security configuration that applies for both webapps, you'll need to setup/install CAS.

Spring Security with Apache CXF jaxrs without using a web.xml

I'm implementing a REST service with Apache CXF and trying to use spring-security for authentication and authorization.
Embedded Jetty has been used as the container thus not using a web.xml.
How can I initialize spring-security filter chain with Apache CXF without using a web.xml?
If you use Servlet API 3.1 you can implement AbstractSecurityWebApplicationInitializer, see Spring Security Reference:
import org.springframework.security.web.context.*;
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
}
This would simply only register the springSecurityFilterChain Filter for every URL in your application.

grails command line application

I have a grails web application with a domain model and a hibernate datasource persistence.
I would like to write now a command line tool in groovy to access also this domain model and the hibernate datasource.
Any ideas how I can do this?
regards
Vanigor
You can use Spring Boot as described in this article.
That example creates a small web UI, but Boot can be configured as a CLI app.

Consuming a WSDL in Grails

I have been handed a .WSDL file which I need to test within a Grails Framework.
Any suggestions how to go about this.
Take a look at the http://grails.org/plugin/cxf and http://grails.org/plugin/cxf-client plugins. They're easy to use and backed by Apache CXF - https://cxf.apache.org/
The client plugin has a wsdl2java script that will generate code that you can use in your Grails app.
You could start with documentation itself: http://grails.org/Calling+External+WebServices

What is the best way to work with services in grails

I've just started a project on grails and didn't find how to work with services using dependency injection and interfaces.
As I've seen so far in the documentation when you create a service - it's just a groovy class which can be auto wired wherever I want.
But what if I want to have an interface for a service and to inject one of its implementation like I did in Java using spring?
eg I want to have a service interface. let it be MyService.groovy
it will have 1 method doSmth()
and I'll have 2 implementations - MyServiceImpl1.groovy and MyServiceImpl2.groovy
I have a quartz job doing something like this
def myService
myService.doSmth()
Where should I put groovy interface (folder)? Shall I create a package for that in src/groovy?
How to configure resources.groovy to wire "myService" with 1 of the service implementation?
Any thoughts are appreciated
Thanks in advance!
Running grails create-service [name] is a convenient way of get a service deployed, but it doesn't create an interface with implementation, as you're looking for.
I'd suggest putting your interface and implementations into src/groovy and using resources.groovy to wire them up (you can access the environment, if you want to deploy a different implementation by environment).
Take a look at the 'Using the Spring DSL' section in chapter 14.2 of the user guide for how to wire up your service in resources.groovy. You also have the option of using resources.xml if you want to wire with XML, but I'd definitely recommend the Groovy DSL.
Just run grails create-service [name]

Resources