@Validated @Test
public void testGet() throws Exception {
Server server = new Server();
SocketListener listener = new SocketListener();
server.addListener(listener);
HttpContext context = new HttpContext(server, "/*");
HttpHandler handler = new AbstractHttpHandler() {
public void handle(String pathInContext, String pathParams,
HttpRequest request, HttpResponse response) throws HttpException, IOException {
try {
SOAPMessage message = MessageFactory.newInstance().createMessage();
SOAPBody body = message.getSOAPBody();
body.addChildElement("root");
response.setContentType(SOAPConstants.SOAP_1_1_CONTENT_TYPE);
message.writeTo(response.getOutputStream());
request.setHandled(true);
} catch (SOAPException ex) {
throw new RuntimeException("Failed to generate SOAP message", ex);
}
}
};
context.addHandler(handler);
server.start();
try {
SOAPConnectionFactory sf = new SOAPConnectionFactoryImpl();
SOAPConnection con = sf.createConnection();
URL urlEndpoint = new URL("http", "localhost", listener.getPort(), "/test");