Source Code Cross Referenced for A_WebServicesEndpoint.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » examples » clients » webservices » 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.jonas.examples.clients.webservices 
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 1any 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: A_WebServicesEndpoint.java 7547 2005-10-20 15:03:58Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.examples.clients.webservices;
025:
026:        import java.io.File;
027:        import java.io.FileInputStream;
028:        import java.util.Properties;
029:
030:        import javax.wsdl.Definition;
031:        import javax.wsdl.Port;
032:        import javax.wsdl.Service;
033:        import javax.wsdl.extensions.soap.SOAPAddress;
034:        import javax.wsdl.factory.WSDLFactory;
035:        import javax.wsdl.xml.WSDLReader;
036:        import javax.xml.namespace.QName;
037:
038:        import com.meterware.httpunit.WebForm;
039:        import com.meterware.httpunit.WebLink;
040:        import com.meterware.httpunit.WebResponse;
041:
042:        /**
043:         * Define a class to test the webServices examples wsWarExample
044:         * Test WebServices deployment OK and test Call on deployed WebService
045:         * @author Guillaume Sauthier
046:         */
047:        public abstract class A_WebServicesEndpoint extends A_WebServices {
048:
049:            /**
050:             * property name => file1 WSDLHandler is mandatory for this test !
051:             */
052:            private static final String JPROP_WSDL_LOCATION = "jonas.service.publish.file.directory";
053:
054:            public A_WebServicesEndpoint(String s, String urlPrefix) {
055:                super (s, urlPrefix);
056:            }
057:
058:            public A_WebServicesEndpoint(String s, String urlPrefix,
059:                    String username, String password) {
060:                super (s, urlPrefix, username, password);
061:            }
062:
063:            /**
064:             * Check if Axis is Running
065:             * @param idServicesLink indicate where is the link to /services in the homepage
066:             * @param portName the name of the port we want to check
067:             * @throws Exception if an error occurs
068:             */
069:            public void checkAxisServicesAccessible(int idServicesLink,
070:                    String context, String portName) throws Exception {
071:
072:                WebResponse wr = wc.getResponse(url + "index.html");
073:                WebLink services = wr.getLinks()[idServicesLink];
074:
075:                // click the link
076:                WebResponse swr = services.click();
077:
078:                // traverse the links and find the interresting one.
079:                boolean found = false;
080:                for (int i = 0; i < swr.getLinks().length; i++) {
081:                    String ws_url = swr.getLinks()[i].getURLString();
082:                    if (ws_url.equalsIgnoreCase(url + context + "/" + portName
083:                            + "?jwsdl"))
084:                        found = true;
085:                }
086:                if (!found)
087:                    fail("endpoint '" + portName + "' not found in /" + context);
088:
089:            }
090:
091:            /**
092:             * Check if WSDL is generated
093:             * @param idWSDLServiceLink indicate where we can find the link
094:             *        to WSDL of the port we want to test. (first, second, ...)
095:             * @throws Exception if an error occurs
096:             */
097:            public void checkAxisWSDL(String path) throws Exception {
098:
099:                WebResponse wr = wc.getResponse(url + path);
100:                assertEquals("Must be an XML mime type", "text/xml", wr
101:                        .getContentType());
102:
103:            }
104:
105:            /**
106:             * Check if deployed WebService is running
107:             * @param formPage the filename of the webpage containing the form
108:             * @param endpoint the URL where local service can be found
109:             * @param name the name to set as parameter
110:             * @param pageTitle title of the returned page
111:             * @throws Exception if an error occurs
112:             */
113:            public void checkDeployedWebService(String formPage,
114:                    String endpoint, String name, String pageTitle)
115:                    throws Exception {
116:
117:                // Get the page containing the form
118:                WebResponse wr = wc.getResponse(url + formPage);
119:
120:                // get the form named "prepare"
121:                WebForm form = wr.getFormWithName("prepare");
122:                // set all parameters
123:                form.setParameter("name", name);
124:                // submit
125:                WebResponse wr2 = form.submit();
126:
127:                String text = wr2.getText();
128:
129:                String valTitle = "<title>" + pageTitle + "</title>";
130:                String valURL = "Working with URL : <i>" + endpoint
131:                        + "</i><br/>";
132:                String valHello = "<b>result of sayHello(name) method :</b><i>Hello "
133:                        + name + "</i><br/>";
134:                String valQuotes = "<b>result of getCotes() method :</b><i>12</i><br/>";
135:
136:                assertTrue("incorrect title", (text.indexOf(valTitle) != -1));
137:                assertTrue("incorrect URL", (text.indexOf(valURL) != -1));
138:                assertTrue("incorrect Name", (text.indexOf(valHello) != -1));
139:                assertTrue("incorrect Cotes", (text.indexOf(valQuotes) != -1));
140:
141:            }
142:
143:            /**
144:             * Check if WSDL has been published.
145:             * @param wsdlFilename the filename of the WSDL file
146:             * @param tns targetNameSpace of the Definition
147:             * @param serviceName the localpart of the Service QName
148:             * @param portName the name of the WSDL' Port
149:             * @param endpoint the expected URL
150:             * @throws Exception if an error occurs
151:             */
152:            public void checkWSDLPublication(String wsdlFilename, String tns,
153:                    String serviceName, String portName, String endpoint)
154:                    throws Exception {
155:
156:                String jonasbase = System.getProperty("jonas.base");
157:                Properties props = new Properties();
158:                props.load(new FileInputStream(new File(jonasbase,
159:                        "conf/file1.properties")));
160:                String wsdlLoc = props.getProperty(JPROP_WSDL_LOCATION);
161:
162:                File wsdl = new File(wsdlLoc, wsdlFilename);
163:
164:                assertTrue("WSDL is not created", wsdl.exists());
165:                assertTrue("WSDL is not a file", wsdl.isFile());
166:
167:                WSDLFactory f = WSDLFactory.newInstance();
168:                WSDLReader r = f.newWSDLReader();
169:
170:                r.setFeature("javax.wsdl.verbose", true);
171:                r.setFeature("javax.wsdl.importDocuments", false);
172:
173:                Definition def = r.readWSDL(wsdl.getPath());
174:                Service s = def.getService(new QName(tns, serviceName));
175:                Port p = s.getPort(portName);
176:                SOAPAddress sa = (SOAPAddress) p.getExtensibilityElements()
177:                        .get(0);
178:
179:                assertEquals("URL has not been updated", endpoint, sa
180:                        .getLocationURI());
181:
182:            }
183:
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.