Source Code Cross Referenced for JOnASJaxRpcClientServlet.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » wssample » servlets » wsclient » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.wssample.servlets.wsclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2005 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JOnASJaxRpcClientServlet.java 7546 2005-10-20 15:00:56Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.wssample.servlets.wsclient;
025:
026:        import java.io.IOException;
027:        import java.io.PrintWriter;
028:
029:        import javax.naming.Context;
030:        import javax.naming.InitialContext;
031:        import javax.naming.NamingException;
032:        import javax.servlet.ServletConfig;
033:        import javax.servlet.ServletException;
034:        import javax.servlet.http.HttpServlet;
035:        import javax.servlet.http.HttpServletRequest;
036:        import javax.servlet.http.HttpServletResponse;
037:        import javax.xml.rpc.ServiceException;
038:        import javax.xml.rpc.Stub;
039:
040:        import org.objectweb.wssample.gen.jaxrpc.JaxRpcEndpointInterface;
041:        import org.objectweb.wssample.gen.jaxrpc.JaxRpcEndpointInterfaceService;
042:
043:        /**
044:         * @author Guillaume Sauthier
045:         */
046:        public class JOnASJaxRpcClientServlet extends HttpServlet {
047:
048:            /**
049:             * Initializes the servlet.
050:             * @param config ServletConfig
051:             * @throws ServletException thrown by super.init(config);
052:             */
053:            public void init(ServletConfig config) throws ServletException {
054:                super .init(config);
055:            }
056:
057:            /**
058:             * Destroys the servlet.
059:             */
060:            public void destroy() {
061:
062:            }
063:
064:            /**
065:             * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
066:             * methods.
067:             *
068:             * @param request servlet request
069:             * @param response servlet response
070:             *
071:             * @throws ServletException default servlet exception thrown
072:             * @throws IOException servlet exception thrown
073:             */
074:            protected void processRequest(HttpServletRequest request,
075:                    HttpServletResponse response) throws ServletException,
076:                    IOException {
077:                response.setContentType("text/html");
078:                PrintWriter out = response.getWriter();
079:
080:                out.println("<html>");
081:                out.println("<head>");
082:                out.println("<title>JOnAS JaxRpc WebService Test Page</title>");
083:                out
084:                        .println("<style type=\"text/css\"> @import \"style/ow_jonas.css\"; </style>");
085:                out.println("</head>");
086:                out.println("<body class=\"bodywelcome\">");
087:
088:                out.println("<div class=\"logos\">");
089:                out
090:                        .println("<a href=\"http://jakarta.apache.org\"><img title=\"Jakarta Tomcat\" alt=\"Jakarta Tomcat\" src=\"images/tomcat.gif\" /></a>");
091:                out
092:                        .println("<a href=\"http://jetty.mortbay.org/jetty/\"><img title=\"Mortbay Jetty\" alt=\"Mortbay Jetty\" src=\"images/jetty.gif\" /></a>");
093:                out
094:                        .println("<a href=\"http://jonas.objectweb.org\"><img title=\"JOnAS WebSite\" alt=\"JOnAS WebSite\" src=\"images/ow_jonas_logo.gif\" /></a>");
095:                out.println("</div>");
096:
097:                // do we need to use the encrypted endpoint or not ?
098:                boolean encrypt = false;
099:                if ("true".equalsIgnoreCase(request.getParameter("encrypt"))) {
100:                    encrypt = true;
101:                }
102:
103:                try {
104:
105:                    // Get the service instance
106:                    //---------------------------------------------
107:                    Context ctx = new InitialContext();
108:                    JaxRpcEndpointInterfaceService service = null;
109:                    JaxRpcEndpointInterface port = null;
110:
111:                    // We can use the same service because the 2 ws use the same interface
112:                    // Get the port where execute methods
113:
114:                    if (encrypt) {
115:                        service = (JaxRpcEndpointInterfaceService) ctx
116:                                .lookup("java:comp/env/service/crypted-jaxrpc");
117:                        //---------------------------------------------
118:                        port = service.getEncryptedJaxRpcEndpoint();
119:                    } else {
120:                        service = (JaxRpcEndpointInterfaceService) ctx
121:                                .lookup("java:comp/env/service/jaxrpc");
122:                        //---------------------------------------------
123:                        port = service.getJaxRpcEndpoint1();
124:                    }
125:
126:                    // Use the context username for WSS4JHandler
127:                    ((Stub) port)._setProperty("user", request
128:                            .getUserPrincipal().getName());
129:
130:                    // Execute Methods :
131:                    String hello = port.sayHello(request.getParameter("name"));
132:                    int cotes = port.getCotes();
133:
134:                    if (encrypt) {
135:                        out
136:                                .println("<div class=\"titlepage\">Results With Encryption</div>");
137:                    } else {
138:                        out.println("<div class=\"titlepage\">Results</div>");
139:                    }
140:                    out.println("<div class=\"links\">");
141:
142:                    // Display results :
143:                    out
144:                            .println("Working with URL : <i>"
145:                                    + ((Stub) port)
146:                                            ._getProperty(Stub.ENDPOINT_ADDRESS_PROPERTY)
147:                                    + "</i><br/>");
148:                    out.println("<b>result of sayHello(name) method :</b><i>"
149:                            + hello + "</i><br/>");
150:                    out.println("<b>result of getCotes() method :</b><i>"
151:                            + cotes + "</i><br/>");
152:
153:                    out.println("</div>");
154:                } catch (ServiceException se) {
155:                    out
156:                            .println("<div class=\"titlepage\">Something goes wrong when calling the WebService<br/>");
157:                    se.printStackTrace(out);
158:                    out.println("</div>");
159:                } catch (NamingException ne) {
160:                    out
161:                            .println("<div class=\"titlepage\">Exception while retrieving InitialContext<br/>");
162:                    ne.printStackTrace(out);
163:                    out.println("</div>");
164:                }
165:
166:                out.println("</body>");
167:                out.println("</html>");
168:
169:                out.close();
170:            }
171:
172:            /**
173:             * Handles the HTTP <code>GET</code> method.
174:             *
175:             * @param request servlet request
176:             * @param response servlet response
177:             *
178:             * @throws ServletException default servlet exception thrown
179:             * @throws IOException default servlet exception thrown
180:             */
181:            protected void doGet(HttpServletRequest request,
182:                    HttpServletResponse response) throws ServletException,
183:                    IOException {
184:                processRequest(request, response);
185:            }
186:
187:            /**
188:             * Handles the HTTP <code>POST</code> method.
189:             *
190:             * @param request servlet request
191:             * @param response servlet response
192:             *
193:             * @throws ServletException default servlet exception thrown
194:             * @throws IOException default servlet exception thrown
195:             */
196:            protected void doPost(HttpServletRequest request,
197:                    HttpServletResponse response) throws ServletException,
198:                    IOException {
199:                processRequest(request, response);
200:            }
201:
202:            /**
203:             * @return Returns a short description of the servlet.
204:             */
205:            public String getServletInfo() {
206:                return "Short description";
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.