Source Code Cross Referenced for MsgProvider.java in  » Portal » stringbeans-3.5 » com » nabhinc » ws » soap » 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 » Portal » stringbeans 3.5 » com.nabhinc.ws.soap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        /*
018:         * Modified by Nabh Information Systems, Inc. for Stringbeans Web Services
019:         * Framework.
020:         * 
021:         * Modifications (c) 2005 Nabh Information Systems, Inc.
022:         */
023:
024:        package com.nabhinc.ws.soap;
025:
026:        import org.apache.axis.AxisFault;
027:        import org.apache.axis.MessageContext;
028:        import org.apache.axis.handlers.soap.SOAPService;
029:        import org.apache.axis.description.OperationDesc;
030:        import org.apache.axis.description.ServiceDesc;
031:        import org.apache.axis.i18n.Messages;
032:        import org.apache.axis.message.SOAPBodyElement;
033:        import org.apache.axis.message.SOAPEnvelope;
034:        import org.apache.axis.message.MessageElement;
035:        import org.w3c.dom.Document;
036:        import org.w3c.dom.Element;
037:
038:        import com.nabhinc.ws.server.InterceptorChain;
039:        import com.nabhinc.ws.server.RequestInfo;
040:
041:        import javax.xml.namespace.QName;
042:
043:        import java.lang.reflect.Method;
044:        import java.util.Vector;
045:
046:        /**
047:         * Deal with message-style Java services.  For now, these are services
048:         * with exactly ONE OperationDesc, pointing to a method which looks like
049:         * one of the following:
050:         *
051:         * public Element [] method(Vector v);
052:         * (NOTE : This is silly, we should change it to either be Vector/Vector
053:         * or Element[]/Element[])
054:         *
055:         * public Document method(Document doc);
056:         *
057:         * public void method(MessageContext mc);
058:         *
059:         * @author Doug Davis (dug@us.ibm.com)
060:         * @author Glen Daniels (gdaniels@apache.org)
061:         */
062:        public class MsgProvider {
063:            /**
064:             * Process the message.  Figure out the method "style" (one of the three
065:             * allowed signatures, which has already been determined and cached in
066:             * the OperationDesc) and do the actual invocation.  Note that we don't
067:             * catch exceptions here, preferring to bubble them right up through to
068:             * someone who'll catch it above us.
069:             *
070:             * @param msgContext the active MessageContext
071:             * @param reqEnv the request SOAPEnvelope
072:             * @param resEnv the response SOAPEnvelope (we should fill this in)
073:             * @param obj the service target object
074:             * @throws Exception
075:             */
076:            public void processMessage(MessageContext msgContext,
077:                    SOAPEnvelope reqEnv, SOAPEnvelope resEnv,
078:                    RequestInfo reqInfo, InterceptorChain chain)
079:                    throws Throwable {
080:                OperationDesc operation = msgContext.getOperation();
081:                SOAPService service = msgContext.getService();
082:                ServiceDesc serviceDesc = service.getServiceDescription();
083:                QName opQName = null;
084:
085:                if (operation == null) {
086:                    Vector bodyElements = reqEnv.getBodyElements();
087:                    if (bodyElements.size() > 0) {
088:                        MessageElement element = (MessageElement) bodyElements
089:                                .get(0);
090:                        if (element != null) {
091:                            opQName = new QName(element.getNamespaceURI(),
092:                                    element.getLocalName());
093:                            operation = serviceDesc
094:                                    .getOperationByElementQName(opQName);
095:                        }
096:                    }
097:                }
098:
099:                if (operation == null) {
100:                    throw new AxisFault(Messages.getMessage(
101:                            "noOperationForQName", opQName == null ? "null"
102:                                    : opQName.toString()));
103:                }
104:
105:                Method method = operation.getMethod();
106:                reqInfo.method = method;
107:                reqInfo.methodName = method.getName();
108:
109:                int methodType = operation.getMessageOperationStyle();
110:
111:                if (methodType != OperationDesc.MSG_METHOD_SOAPENVELOPE) {
112:                    // dig out just the body, and pass it on
113:                    Vector bodies = reqEnv.getBodyElements();
114:                    Object argObjects[] = new Object[1];
115:
116:                    switch (methodType) {
117:                    // SOAPBodyElement [] / SOAPBodyElement []
118:                    case OperationDesc.MSG_METHOD_BODYARRAY:
119:                        SOAPBodyElement[] bodyElements = new SOAPBodyElement[bodies
120:                                .size()];
121:                        bodies.toArray(bodyElements);
122:                        argObjects[0] = bodyElements;
123:                        reqInfo.arguments = argObjects;
124:                        boolean redirect = invokeMethod(reqInfo, chain);
125:                        if (redirect)
126:                            return;
127:                        SOAPBodyElement[] bodyResult = (SOAPBodyElement[]) reqInfo.result;
128:                        if (bodyResult != null) {
129:                            for (int i = 0; i < bodyResult.length; i++) {
130:                                SOAPBodyElement bodyElement = bodyResult[i];
131:                                resEnv.addBodyElement(bodyElement);
132:                            }
133:                        }
134:                        return;
135:
136:                        // Element [] / Element []
137:                    case OperationDesc.MSG_METHOD_ELEMENTARRAY:
138:                        Element[] elements = new Element[bodies.size()];
139:                        for (int i = 0; i < elements.length; i++) {
140:                            SOAPBodyElement body = (SOAPBodyElement) bodies
141:                                    .get(i);
142:                            elements[i] = body.getAsDOM();
143:                        }
144:                        argObjects[0] = elements;
145:                        reqInfo.arguments = argObjects;
146:                        redirect = invokeMethod(reqInfo, chain);
147:                        if (redirect)
148:                            return;
149:                        Element[] elemResult = (Element[]) reqInfo.result;
150:                        if (elemResult != null) {
151:                            for (int i = 0; i < elemResult.length; i++) {
152:                                if (elemResult[i] != null)
153:                                    resEnv.addBodyElement(new SOAPBodyElement(
154:                                            elemResult[i]));
155:                            }
156:                        }
157:                        return;
158:
159:                        // Element [] / Element []
160:                    case OperationDesc.MSG_METHOD_DOCUMENT:
161:                        Document doc = ((SOAPBodyElement) bodies.get(0))
162:                                .getAsDocument();
163:                        argObjects[0] = doc;
164:                        reqInfo.arguments = argObjects;
165:                        redirect = invokeMethod(reqInfo, chain);
166:                        if (redirect)
167:                            return;
168:                        Document resultDoc = (Document) reqInfo.result;
169:                        if (resultDoc != null) {
170:                            resEnv.addBodyElement(new SOAPBodyElement(resultDoc
171:                                    .getDocumentElement()));
172:                        }
173:                        return;
174:                    }
175:                } else {
176:                    Object argObjects[] = new Object[2];
177:
178:                    // SOAPEnvelope / SOAPEnvelope
179:                    argObjects[0] = reqEnv;
180:                    argObjects[1] = resEnv;
181:                    invokeMethod(reqInfo, chain);
182:                    return;
183:                }
184:
185:                // SHOULD NEVER GET HERE...
186:                throw new AxisFault(Messages.getMessage("badMsgMethodStyle"));
187:            }
188:
189:            private boolean invokeMethod(RequestInfo reqInfo,
190:                    InterceptorChain chain) throws Throwable {
191:                // Invoke interceptor chain. At the end of interceptor chain,
192:                // WebServiceInterceptorChain object will invoke the actual
193:                // service method.
194:                /*
195:                InterceptorInfo[] ints = 
196:                	InterceptorManager.getInterceptorChain(reqInfo.serviceInfo.name, reqInfo.methodName);
197:                InterceptorChain chain = new InterceptorChain(ints);
198:                 */
199:                chain.doIntercept(reqInfo);
200:                if (reqInfo.redirect != null)
201:                    return true;
202:                if (reqInfo.error != null)
203:                    throw reqInfo.error;
204:                return false;
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.