Dropwizard-JAXWS is a Dropwizard Bundle that enables building SOAP web services and clients using JAX-WS API with Dropwizard.
- Uses Apache CXF web services framework (no Spring Framework dependency).
- Java First and WSDL first service development.
- Using standard JAX-WS annotations, without custom deployment descriptors.
- Metrics instrumentation: @Metered, @Timed and @ExceptionMetered annotations.
- Dropwizard validation support.
- Dropwizard Hibernate support (@UnitOfWork).
- Dropwizard basic authentication using Dropwizard Authenticator.
- Web service client factory.
SOAP service:
@Metered
@WebService
public HelloWorldSOAP {
@WebMethod
public String sayHello() {
return "Hello world!";
}
}
Dropwizard application:
public class MyApplication extends Application<MyApplicationConfiguration> {
private JAXWSBundle jaxWsBundle = new JAXWSBundle();
@Override
public void initialize(Bootstrap<MyApplicationConfiguration> bootstrap) {
bootstrap.addBundle(jaxWsBundle);
}
@Override
public void run(MyApplicationConfiguration configuration, Environment environment) throws Exception {
jaxWsBundle.publishEndpoint("/hello", new HelloWorldSOAP());
}
public static void main(String[] args) throws Exception {
new MyApplication().run(args);
}
}
Using HelloWorldSOAP web service client:
HelloWorldSOAP helloWorld = jaxWsBundle.getClient(HelloWorldSOAP.class, "http://server/path");
System.out.println(helloWorld.sayHello());
Module dropwizard-jaxws-example contains Dropwizard application (JaxWsExampleApplication) with the following SOAP
web services and RESTful resources:
-
SimpleService: A minimal 'hello world' example.
-
JavaFirstService: Java first development example.
JavaFirstServiceinterface uses JAX-WS annotations.JavaFirstServiceImplcontains service implementation instrumented with Metrics annotations. Service is secured with basic authentication usingdropwizard-auth.BasicAuthenticatorimplements DropwizardAuthenticator.JavaFirstServiceImplaccesses authenticated user properties via injected JAX-WSWebServiceContext. -
WsdlFirstService: WSDL first development example. WSDL is stored in
resources/META-INF/WsdlFirstService.wsdl. Code is generated usingcxf-codegen-pluginwhich is configured inpom.xml.WsdlFirstServiceImplcontains service implementation.WsdlFirstServiceHandlercontains server-side JAX-WS handler. -
HibernateExampleService:
dropwizard-hibernateexample.HibernateExampleServiceimplements the service.@UnitOfWorkannotations are used for defining transactional boundaries.@Validannotation is used for parameter validation oncreatePersonmethod.HibernateExampleServiceaccesses the database throughPersonDAO. Embedded H2 database is used. Database configuration is stored in Dropwizard config fileconfig.yaml. -
AccessProtectedServiceResource: Dropwizard RESTful service which uses
JavaFirstServiceclient to invokeJavaFirstServiceSOAP web service on the same host. User credentials are provided to access protected service. -
AccessWsdlFirstServiceResource: Dropwizard RESTful service which uses
WsdlFirstServiceclient to invokeWsdlFirstServiceSOAP web service on the same host.WsdlFirstClientHandlercontains client-side JAX-WS handler.
After cloning the repository, go to the dropwizard-jaxws root folder and run:
mvn install
To run the example service:
java -jar dropwizard-jaxws-example\target\dropwizard-jaxws-example-0.2.0.jar server dropwizard-jaxws-example\config.yaml
To use dropwizard-jaxws in your project, add the following dependency to pom.xml:
<dependency>
<groupId>com.roskart.dropwizard</groupId>
<artifactId>dropwizard-jaxws</artifactId>
<version>0.2.0</version>
</dependency>
When using maven-shade-plugin for building fat jar, you must add the following transformer element to plugin
configuration:
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/cxf/bus-extensions.txt</resource>
</transformer>
For example on building fat jar, see dropwizard-jaxws-example/pom.xml.
Apache Software License 2.0, see LICENSE.
- Upgraded to Dropwizard 0.7.0.
- Upgraded to CXF 2.7.8.
- Initial Release (uses Dropwizard 0.6.2).