Java Reference
In-Depth Information
be.addTextNode("Hello, " + name + "!");
msg.saveChanges();
return msg;
}
//Here we inspect HTTP Request headers
@SuppressWarnings("unchecked")
private MimeHeaders getHeaders(HttpServletRequest request)
throws SOAPException {
MimeHeaders headers = new MimeHeaders();
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()){
String key = names.nextElement();
String value = request.getHeader(key);
headers.addHeader(key, value);
System.out.println("Added MIME Header: " +
key + "=" + value);
}
return headers;
}
@Override
public void init() throws ServletException {
super.init();
}
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public SAAJProviderServlet() { }
}
Because you're just clicking a link, the HTTP method will come in as a GET, and you'll just
forward that to the doPost override. You do some basic housekeeping here, such as setting
the content MIME type and setting the HTTP status code to 200. And then you do some real-
world things, like adding a custom header that can be useful in a chain.
Here's the real meat and potatoes of this example: you can use the request to get an input
stream that can be used in constructing the SOAP message for the response. You'll have ac-
Search WWH ::




Custom Search