Source Code Cross Referenced for RPCMessageReceiver.java in  » Web-Services-AXIS2 » adb » org » apache » axis2 » rpc » receivers » 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 » Web Services AXIS2 » adb » org.apache.axis2.rpc.receivers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:
020:        /*
021:         * Reflection based RPCMessageReceiver , request will be processed by looking at the method signature
022:         * of the invocation method
023:         */
024:        package org.apache.axis2.rpc.receivers;
025:
026:        import org.apache.axiom.om.OMElement;
027:        import org.apache.axiom.om.OMNamespace;
028:        import org.apache.axiom.soap.SOAPEnvelope;
029:        import org.apache.axiom.soap.SOAPFactory;
030:        import org.apache.axis2.AxisFault;
031:        import org.apache.axis2.context.MessageContext;
032:        import org.apache.axis2.description.*;
033:        import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
034:        import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
035:        import org.apache.axis2.wsdl.WSDLConstants;
036:        import org.apache.commons.logging.Log;
037:        import org.apache.commons.logging.LogFactory;
038:
039:        import java.lang.reflect.InvocationTargetException;
040:        import java.lang.reflect.Method;
041:
042:        public class RPCMessageReceiver extends AbstractInOutMessageReceiver {
043:            private static Log log = LogFactory
044:                    .getLog(RPCMessageReceiver.class);
045:
046:            /**
047:             * reflect and get the Java method - for each i'th param in the java method - get the first
048:             * child's i'th child -if the elem has an xsi:type attr then find the deserializer for it - if
049:             * not found, lookup deser for th i'th param (java type) - error if not found - deserialize &
050:             * save in an object array - end for
051:             * <p/>
052:             * - invoke method and get the return value
053:             * <p/>
054:             * - look up serializer for return value based on the value and type
055:             * <p/>
056:             * - create response msg and add return value as grand child of <soap:body>
057:             *
058:             * @param inMessage incoming MessageContext
059:             * @param outMessage outgoing MessageContext
060:             * @throws AxisFault
061:             */
062:
063:            public void invokeBusinessLogic(MessageContext inMessage,
064:                    MessageContext outMessage) throws AxisFault {
065:                Method method = null;
066:                try {
067:                    // get the implementation class for the Web Service
068:                    Object obj = getTheImplementationObject(inMessage);
069:
070:                    Class ImplClass = obj.getClass();
071:
072:                    AxisOperation op = inMessage.getOperationContext()
073:                            .getAxisOperation();
074:                    method = (Method) (op.getParameterValue("myMethod"));
075:                    AxisService service = inMessage.getAxisService();
076:                    OMElement methodElement = inMessage.getEnvelope().getBody()
077:                            .getFirstElement();
078:                    AxisMessage inAxisMessage = op
079:                            .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
080:                    String messageNameSpace = null;
081:
082:                    if (method == null) {
083:                        String methodName = op.getName().getLocalPart();
084:                        Method[] methods = ImplClass.getMethods();
085:
086:                        for (int i = 0; i < methods.length; i++) {
087:                            if (methods[i].getName().equals(methodName)) {
088:                                method = methods[i];
089:                                op.addParameter("myMethod", method);
090:                                break;
091:                            }
092:                        }
093:                        if (method == null) {
094:                            throw new AxisFault("No such method '" + methodName
095:                                    + "' in class " + ImplClass.getName());
096:                        }
097:                    }
098:                    Object resObject = null;
099:                    if (inAxisMessage != null) {
100:                        resObject = RPCUtil.invokeServiceClass(inAxisMessage,
101:                                method, obj, messageNameSpace, methodElement,
102:                                inMessage);
103:                    }
104:
105:                    SOAPFactory fac = getSOAPFactory(inMessage);
106:
107:                    // Handling the response
108:                    AxisMessage outaxisMessage = op
109:                            .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
110:                    if (outaxisMessage != null
111:                            && outaxisMessage.getElementQName() != null) {
112:                        messageNameSpace = outaxisMessage.getElementQName()
113:                                .getNamespaceURI();
114:                    } else {
115:                        messageNameSpace = service.getTargetNamespace();
116:                    }
117:
118:                    OMNamespace ns = fac.createOMNamespace(messageNameSpace,
119:                            service.getSchemaTargetNamespacePrefix());
120:                    SOAPEnvelope envelope = fac.getDefaultEnvelope();
121:                    OMElement bodyContent = null;
122:
123:                    if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(op
124:                            .getMessageExchangePattern())) {
125:                        OMElement bodyChild = fac.createOMElement(outMessage
126:                                .getAxisMessage().getName(), ns);
127:                        envelope.getBody().addChild(bodyChild);
128:                        outMessage.setEnvelope(envelope);
129:                        return;
130:                    }
131:                    Parameter generateBare = service
132:                            .getParameter(Java2WSDLConstants.DOC_LIT_BARE_PARAMETER);
133:                    if (generateBare != null
134:                            && "true".equals(generateBare.getValue())) {
135:                        RPCUtil.processResonseAsDocLitBare(resObject, service,
136:                                envelope, fac, ns, bodyContent, outMessage);
137:                    } else {
138:                        RPCUtil.processResponseAsDocLitWrapped(resObject,
139:                                service, method, envelope, fac, ns,
140:                                bodyContent, outMessage);
141:                    }
142:                    outMessage.setEnvelope(envelope);
143:                } catch (InvocationTargetException e) {
144:                    String msg = null;
145:                    Throwable cause = e.getCause();
146:                    if (cause != null) {
147:                        msg = cause.getMessage();
148:                    }
149:                    if (msg == null) {
150:                        msg = "Exception occurred while trying to invoke service method "
151:                                + method.getName();
152:                    }
153:                    if (cause instanceof  AxisFault) {
154:                        log.debug(msg, cause);
155:                        throw (AxisFault) cause;
156:                    }
157:                    log.error(msg, e);
158:                    throw new AxisFault(msg, e);
159:                } catch (RuntimeException e) {
160:                    throw AxisFault.makeFault(e);
161:                } catch (Exception e) {
162:                    String msg = "Exception occurred while trying to invoke service method "
163:                            + method.getName();
164:                    log.error(msg, e);
165:                    throw AxisFault.makeFault(e);
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.