I need to create a java SOAP service but I don't have good access to the environment the service will be deployed. I am only allowed to create simple Servlets. I am allowed to include libs in my project but not static xml files (for example WSDL files) etc.
So I am looking for some lib that can take a HttpServletRequest and either produce a WSDL xml dynamically (if the request is GET and includes ?wsdl in the query string), or process the incoming SOAP request (if the request is POST).
Ideally I would like to utilize jws annotations for this.
So here is my sample code:
Service Interface:
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface IMyService {
@WebMethod
public String echo(String string);
}
Service Implementation:
public class MyService implements IMyService {
@Override
public String echo(String string) {
return string;
}
}
The Servlet:
public class TheService extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) {
// CODE HERE TO HANDLE THE GET.
// IF REQUEST CONTAINS ?wsdl, IT SHOULD DYNAMICALLY BUILD THE WSDL XML AND SERVICE IT
xml = someSOAPLib.produceWSDL(request);
response.setContentType("application/xml");
outputStream = response.getOutputStream();
outputStream.write(xml.getBytes());
}
public void doPost(HttpServletRequest request, HttpServletResponse response) {
// CODE HERE TO HANDLE THE POST.
// IT SHOULD PROCESS THE SOAP REQUEST AND RETURN A SOAP RESPONSE
xml = someSOAPLib.processSOAPRequest(request);
response.setContentType("application/xml");
outputStream = response.getOutputStream();
outputStream.write(xml.getBytes());
}
}
I would guess that either Apache CXF or AXIS would be able to do this but I cannot find any docs/sample code on how to do it.