/** * soap本质上走的是http协议,所以获取body内容,通过post方式调用soap服务,再获取结果,以xml形式返回 * 代码基于resty,和jfinal有少许差别,改动也容易 */ @POST public void proxySoap() throws IOException { int len = getRequest().getContentLength(); InputStream is = getRequest().getContentStream(); byte[] buffer = new byte[len]; is.read(buffer, 0, len); String data = new String(buffer, "UTF-8"); Map<String, String> headers = getRequest().getHeaders(); String clientIp = getRequest().getClientAddress(); headers.put("X_REAL_IP", clientIp); // 加上真实调用方IP String url = Proper.get("realservice"); String ret = HttpKit.post(url, data, headers); HttpResponse response = this.getResponse(); response.setContentType("application/xml"); response.getWriter().write(ret); }