Source Code Cross Referenced for SoapMessageContext.java in  » Web-Services-AXIS2 » jax-ws » org » apache » axis2 » jaxws » handler » 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 » jax ws » org.apache.axis2.jaxws.handler 
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:        package org.apache.axis2.jaxws.handler;
020:
021:        import org.apache.axis2.jaxws.ExceptionFactory;
022:        import org.apache.axis2.jaxws.core.MessageContext;
023:        import org.apache.axis2.jaxws.i18n.Messages;
024:        import org.apache.axis2.jaxws.message.Block;
025:        import org.apache.axis2.jaxws.message.Message;
026:        import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
027:        import org.apache.axis2.jaxws.message.factory.BlockFactory;
028:        import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
029:        import org.apache.axis2.jaxws.message.factory.MessageFactory;
030:        import org.apache.axis2.jaxws.registry.FactoryRegistry;
031:        import org.apache.commons.logging.Log;
032:        import org.apache.commons.logging.LogFactory;
033:
034:        import javax.xml.bind.JAXBContext;
035:        import javax.xml.namespace.QName;
036:        import javax.xml.soap.SOAPConstants;
037:        import javax.xml.soap.SOAPMessage;
038:        import javax.xml.stream.XMLStreamException;
039:
040:        import java.util.ArrayList;
041:        import java.util.HashSet;
042:        import java.util.List;
043:        import java.util.Set;
044:
045:        /**
046:         * The SOAPMessageContext is the context handed to SOAP-based application handlers.  It provides
047:         * access to the SOAP message that represents the request or response via SAAJ.  It also allows
048:         * access to any properties that have been registered and set on the MessageContext.
049:         */
050:        public class SoapMessageContext extends BaseMessageContext implements 
051:                javax.xml.ws.handler.soap.SOAPMessageContext {
052:            private static final Log log = LogFactory
053:                    .getLog(SoapMessageContext.class);
054:
055:            public SoapMessageContext(MessageContext messageCtx) {
056:                super (messageCtx);
057:            }
058:
059:            public Object[] getHeaders(QName qname, JAXBContext jaxbcontext,
060:                    boolean flag) {
061:                if (log.isDebugEnabled()) {
062:                    log.debug("Getting all Headers for Qname: " + qname);
063:                }
064:
065:                if (qname == null) {
066:                    if (log.isDebugEnabled()) {
067:                        log.debug("Invalid QName, QName cannot be null");
068:                    }
069:                    ExceptionFactory.makeWebServiceException(Messages
070:                            .getMessage(""));
071:                }
072:                if (jaxbcontext == null) {
073:                    if (log.isDebugEnabled()) {
074:                        log
075:                                .debug("Invalid JAXBContext, JAXBContext cannot be null");
076:                    }
077:                    ExceptionFactory.makeWebServiceException(Messages
078:                            .getMessage("SOAPMessageContextErr2"));
079:                }
080:
081:                if (flag == false) {
082:                    //TODO: Implement, In this case we need to only return headers targetted at roles 
083:                    // currently played by this SOAPNode. 
084:
085:                }
086:                List<Object> list = new ArrayList<Object>();
087:                String namespace = qname.getNamespaceURI();
088:                String localPart = qname.getLocalPart();
089:                BlockFactory blockFactory = (JAXBBlockFactory) FactoryRegistry
090:                        .getFactory(JAXBBlockFactory.class);
091:                Message m = messageCtx.getMessage();
092:                JAXBBlockContext jbc = new JAXBBlockContext(jaxbcontext);
093:                if (m.getNumHeaderBlocks() > 0) {
094:                    Block hb = m.getHeaderBlock(namespace, localPart, jbc,
095:                            blockFactory);
096:                    if (hb != null) {
097:                        try {
098:
099:                            Object bo = hb.getBusinessObject(false);
100:                            if (bo != null) {
101:                                if (log.isDebugEnabled()) {
102:                                    log.debug("Extracted BO from Header Block");
103:                                }
104:                                list.add(bo);
105:                            }
106:
107:                        } catch (XMLStreamException e) {
108:                            ExceptionFactory.makeWebServiceException(e);
109:                        }
110:                    }
111:                }
112:                return list.toArray(new Object[0]);
113:
114:            }
115:
116:            public SOAPMessage getMessage() {
117:                Message msg = messageCtx.getMEPContext().getMessageObject();
118:                return msg.getAsSOAPMessage();
119:            }
120:
121:            public Set<String> getRoles() {
122:                // TODO implement better.  We should be doing smarter checking of the header,
123:                // especially for the Ultimate receiver actor/role
124:
125:                /*
126:                 * JAVADOC to help get this implemented correctly:
127:                 * 
128:                 * Gets the SOAP actor roles associated with an execution of the handler
129:                 * chain. Note that SOAP actor roles apply to the SOAP node and are
130:                 * managed using SOAPBinding.setRoles and SOAPBinding.getRoles. Handler
131:                 * instances in the handler chain use this information about the SOAP
132:                 * actor roles to process the SOAP header blocks. Note that the SOAP
133:                 * actor roles are invariant during the processing of SOAP message
134:                 * through the handler chain.
135:                 */
136:
137:                HashSet<String> roles = new HashSet<String>(3);
138:                // JAX-WS 10.1.1.1 defaults:
139:                // SOAP 1.1
140:                roles.add(SOAPConstants.URI_SOAP_ACTOR_NEXT);
141:                // SOAP 1.2
142:                roles.add(SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER);
143:                roles.add(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
144:                return roles;
145:            }
146:
147:            public void setMessage(SOAPMessage soapmessage) {
148:                // TODO I don't like this at all.
149:                try {
150:                    Message msg = ((MessageFactory) FactoryRegistry
151:                            .getFactory(MessageFactory.class))
152:                            .createFrom(soapmessage);
153:                    messageCtx.getMEPContext().setMessage(msg);
154:                } catch (XMLStreamException e) {
155:                    // TODO log it, and throw something?
156:                }
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.