Source Code Cross Referenced for Axis2WsContainerTest.java in  » J2EE » openejb3 » org » apache » openejb » server » axis2 » 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 » openejb3 » org.apache.openejb.server.axis2 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *       http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        package org.apache.openejb.server.axis2;
018:
019:        import org.apache.openejb.core.webservices.PortData;
020:        import org.apache.openejb.server.axis2.pojo.PojoWsContainer;
021:        import org.apache.openejb.server.axis2.testdata.simple.HelloWorld;
022:        import org.apache.openejb.server.httpd.HttpRequest;
023:        import org.w3c.dom.Element;
024:        import org.w3c.dom.NamedNodeMap;
025:        import org.w3c.dom.NodeList;
026:
027:        import java.io.ByteArrayOutputStream;
028:        import java.net.URI;
029:        import java.util.HashMap;
030:
031:        public class Axis2WsContainerTest extends Axis2AbstractTestCase {
032:            private final String RESOURCE_PATH = testDir + "/resources/";
033:
034:            public Axis2WsContainerTest(String testName) {
035:                super (testName);
036:            }
037:
038:            /*
039:            public void testDocInvokeWithWSDL() throws Exception {
040:                invokeWithWSDL("BareDocLitService", "org.apache.openejb.server.axis2.testdata.doclitbare.BareDocLitService",
041:                               "test_service_doclitbare.wsdl", "test_service_doclitbare_request.xml");
042:            }
043:             */
044:
045:            public void testRPCInvokeWithWSDL() throws Exception {
046:                invokeWithWSDL(
047:                        "RpcLitService",
048:                        "org.apache.openejb.server.axis2.testdata.rpclit.RpcLitService",
049:                        "test_service_rpclit.wsdl",
050:                        "test_service_rpclit_request.xml");
051:            }
052:
053:            public void XtestGetWSDL() throws Exception {
054:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
055:
056:                PortData port = new PortData();
057:                port.setLocation("/axis2/HelloWorld");
058:
059:                Axis2Request req = new Axis2Request(504,
060:                        "text/xml; charset=utf-8", null,
061:                        HttpRequest.Method.GET, new HashMap<String, String>(),
062:                        new URI("/axis2/HelloWorld?wsdl"),
063:                        new HashMap<String, String>(), "127.0.0.1");
064:                ByteArrayOutputStream out = new ByteArrayOutputStream();
065:                Axis2Response res = new Axis2Response(
066:                        "text/xml; charset=utf-8", "127.0.0.1", null, null,
067:                        8080, out);
068:
069:                PojoWsContainer container = new PojoWsContainer(port,
070:                        HelloWorld.class, null, "/axis2");
071:                container.start();
072:                container.onMessage(req, res);
073:                out.flush();
074:
075:            }
076:
077:            private void invokeWithWSDL(String serviceName,
078:                    String endPointClassName, String wsdl, String requestFile)
079:                    throws Exception {
080:                //        ClassLoader cl = Thread.currentThread().getContextClassLoader();
081:                //        InputStream in = cl.getResourceAsStream(requestFile);
082:                //
083:                //        //This will reduce number of requests files
084:                //        DocumentBuilder documentBuilder = XmlUtil.newDocumentBuilderFactory().newDocumentBuilder();
085:                //        Document doc = documentBuilder.parse(in);
086:                //
087:                //        Element root = doc.getDocumentElement();
088:                //        NodeList nodeList = root.getElementsByTagName("soap:Envelope");
089:                //
090:                //        InputStream request;
091:                //
092:                //        for(int i = 0; i < nodeList.getLength(); i++){
093:                //        	StringBuffer envelope = new StringBuffer("<soap:Envelope");
094:                //        	Element element = (Element)nodeList.item(i);
095:                //        	NamedNodeMap attributes = element.getAttributes();
096:                //        	if(attributes != null){
097:                //        		for(int k=0; k < attributes.getLength(); k++){
098:                //        			envelope.append(" "+attributes.item(k).getNodeName().trim());
099:                //        			envelope.append("=\""+attributes.item(k).getNodeValue().trim()+"\"");
100:                //        		}
101:                //        		String content = element.getTextContent();
102:                //
103:                //        		if(content != null && !content.equals("")){
104:                //        			envelope.append(">");
105:                //
106:                //            		NodeList children = element.getChildNodes();
107:                //            		if(children != null){
108:                //            			for(int j=0; j < children.getLength(); j++){
109:                //            				if(children.item(j).getNodeType() == org.w3c.dom.Node.ELEMENT_NODE){
110:                //                    			Element child = (Element)children.item(j);
111:                //                    			envelope.append(getElementContent(child).trim());
112:                //                			}else if(children.item(j).getNodeType() == org.w3c.dom.Node.TEXT_NODE){
113:                //                				envelope.append(children.item(j).getNodeValue().trim());
114:                //                			}
115:                //                		}
116:                //            		}
117:                //            		envelope.append("</soap:Envelope>");
118:                //        		}else {
119:                //        			envelope.append("/>");
120:                //        		}
121:                //        	}
122:                //
123:                //            System.out.println(envelope.toString());
124:                //
125:                //            request = new ByteArrayInputStream(envelope.toString().getBytes("UTF-8"));
126:                //
127:                //            PortInfo portInfo = new PortInfo();
128:                //            portInfo.location = "/axis2/" + serviceName;
129:                //
130:                //            File wsdlFile = new File(RESOURCE_PATH + wsdl);
131:                //            portInfo.wsdlFile = wsdlFile.toURL().toString();
132:                //
133:                //            try {
134:                //                Axis2Request req = new Axis2Request(504,
135:                //                        "text/xml; charset=utf-8",
136:                //                        request,
137:                //                        HttpRequest.POST,
138:                //                        new HashMap<String,String>(),
139:                //                        new URI("/axis2/"+serviceName),
140:                //                        new HashMap<String,String>(),
141:                //                        "127.0.0.1");
142:                //
143:                //                ByteArrayOutputStream out = new ByteArrayOutputStream();
144:                //                Axis2Response res = new Axis2Response("text/xml; charset=utf-8", "127.0.0.1", null, null, 8080, out);
145:                //
146:                //                POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endPointClassName, cl, null, null, Holder.EMPTY, "/axis2");
147:                //                container.init();
148:                //                container.onMessage(req, res);
149:                //                System.out.println("Response "+out);
150:                //                out.flush();
151:                //
152:                //            } catch (Throwable ex) {
153:                //                ex.printStackTrace();
154:                //                throw new Exception(ex.toString());
155:                //            } finally {
156:                //                if (request != null) {
157:                //                    try {
158:                //                        request.close();
159:                //                    } catch (IOException ignore) {
160:                //                        // ignore
161:                //                    }
162:                //                }
163:                //            }
164:                //        }
165:            }
166:
167:            private String getElementContent(Element e) {
168:                StringBuffer content = new StringBuffer("<" + e.getNodeName());
169:                NamedNodeMap attributes = e.getAttributes();
170:
171:                if (attributes != null) {
172:                    for (int k = 0; k < attributes.getLength(); k++) {
173:                        content.append(" " + attributes.item(k).getNodeName());
174:                        content.append("=\""
175:                                + attributes.item(k).getNodeValue() + "\"");
176:                    }
177:                }
178:
179:                String value = e.getTextContent();
180:
181:                if (value != null && !value.equals("")) {
182:                    content.append(">");
183:
184:                    NodeList children = e.getChildNodes();
185:                    if (children != null) {
186:                        for (int j = 0; j < children.getLength(); j++) {
187:                            if (children.item(j).getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
188:                                Element child = (Element) children.item(j);
189:                                content.append(getElementContent(child).trim());
190:                            } else if (children.item(j).getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
191:                                content.append(children.item(j).getNodeValue()
192:                                        .trim());
193:                            }
194:                        }
195:                    }
196:                    content.append("</" + e.getNodeName() + ">");
197:                } else {
198:                    content.append("/>");
199:                }
200:
201:                return content.toString();
202:            }
203:
204:            protected void setUp() throws Exception {
205:            }
206:
207:            protected void tearDown() throws Exception {
208:            }
209:
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.