01: /*
02: * de.schlund.pfixcore.webservice.SOAPActionRequestWrapper
03: */
04: package de.schlund.pfixcore.webservice;
05:
06: import java.io.BufferedReader;
07: import java.io.ByteArrayInputStream;
08: import java.io.IOException;
09: import java.io.InputStreamReader;
10:
11: import javax.servlet.ServletInputStream;
12: import javax.servlet.http.HttpServletRequest;
13: import javax.servlet.http.HttpServletRequestWrapper;
14:
15: /**
16: * SOAPActionRequestWrapper.java
17: *
18: * Created: 16.08.2004
19: *
20: * @author mleidig
21: */
22: public class SOAPActionRequestWrapper extends HttpServletRequestWrapper {
23:
24: String soapMsg;
25: String soapAction = "\"\"";
26: MyServletInputStream myIn;
27:
28: public SOAPActionRequestWrapper(HttpServletRequest req)
29: throws IOException {
30: super (req);
31: if (req.getHeader(Constants.HEADER_SOAP_ACTION) == null) {
32: soapMsg = req.getParameter(Constants.PARAM_SOAP_MESSAGE);
33: if (soapMsg != null) {
34: myIn = new MyServletInputStream();
35: }
36: }
37: }
38:
39: public String getHeader(String name) {
40: if (name.equals("SOAPAction"))
41: return soapAction;
42: return super .getHeader(name);
43: }
44:
45: public ServletInputStream getInputStream() throws IOException {
46: return myIn;
47: }
48:
49: public BufferedReader getReader() throws IOException {
50: return new BufferedReader(new InputStreamReader(myIn));
51: }
52:
53: class MyServletInputStream extends ServletInputStream {
54:
55: ByteArrayInputStream in;
56:
57: public MyServletInputStream() {
58: in = new ByteArrayInputStream(soapMsg.getBytes());
59: }
60:
61: public int read() throws IOException {
62: return in.read();
63: }
64:
65: }
66:
67: }
|