Skip to content

Instantly share code, notes, and snippets.

@cemo
Forked from dmorgantini/AddNumbersService.java
Created September 6, 2012 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemo/3652691 to your computer and use it in GitHub Desktop.
Save cemo/3652691 to your computer and use it in GitHub Desktop.
Use SOAP with dropwizard
package com.example.helloworld.resources;
import javax.jws.WebMethod;
@javax.jws.WebService(
name = "AddNumbersPortType",
serviceName = "AddNumbersService",
targetNamespace = "http://duke.example.org")
@javax.jws.soap.SOAPBinding(
style = javax.jws.soap.SOAPBinding.Style.DOCUMENT,
use = javax.jws.soap.SOAPBinding.Use.LITERAL,
parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED)
public class AddNumbersService {
@WebMethod
public int Add(int a, int b) {
return a + b;
}
}
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.6-2</version>
</dependency>
public class SoapBundle implements Bundle {
@Override
public void initialize(Environment environment) {
environment.addServlet(new com.sun.xml.ws.transport.http.servlet.WSServlet(), "/SOAP/*");
environment.addServletListeners(new com.sun.xml.ws.transport.http.servlet.WSServletContextListener());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="HelloWorld"
implementation="com.example.helloworld.resources.AddNumbersService"
url-pattern="/SOAP/add"/>
</endpoints>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment