01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.superbiz.servlet;
18:
19: import javax.servlet.ServletException;
20: import javax.servlet.ServletOutputStream;
21: import javax.servlet.http.HttpServlet;
22: import javax.servlet.http.HttpServletRequest;
23: import javax.servlet.http.HttpServletResponse;
24: import javax.xml.ws.WebServiceRef;
25: import javax.jws.HandlerChain;
26: import java.io.IOException;
27:
28: public class WebserviceServlet extends HttpServlet {
29:
30: @WebServiceRef
31: @HandlerChain(file="client-handlers.xml")
32: private HelloPojo helloPojo;
33:
34: @WebServiceRef
35: @HandlerChain(file="client-handlers.xml")
36: private HelloEjb helloEjb;
37:
38: protected void doGet(HttpServletRequest request,
39: HttpServletResponse response) throws ServletException,
40: IOException {
41: response.setContentType("text/plain");
42: ServletOutputStream out = response.getOutputStream();
43:
44: OUT = out;
45: try {
46: out.println("Pojo Webservice");
47: out.println(" helloPojo.hello(\"Bob\")="
48: + helloPojo.hello("Bob"));
49: out.println();
50: out.println(" helloPojo.hello(null)="
51: + helloPojo.hello(null));
52: out.println();
53: out.println("EJB Webservice");
54: out.println(" helloEjb.hello(\"Bob\")="
55: + helloEjb.hello("Bob"));
56: out.println();
57: out.println(" helloEjb.hello(null)="
58: + helloEjb.hello(null));
59: out.println();
60: } finally {
61: OUT = out;
62: }
63: }
64:
65: private static ServletOutputStream OUT;
66:
67: public static void write(String message) {
68: try {
69: ServletOutputStream out = OUT;
70: out.println(message);
71: } catch (Exception e) {
72: e.printStackTrace();
73: }
74: }
75: }
|