Source Code Cross Referenced for SoapMessageMUProviderTests.java in  » Web-Services-AXIS2 » jax-ws » org » apache » axis2 » jaxws » provider » 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.provider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004,2005 The Apache Software Foundation.
003:         * Copyright 2007 International Business Machines Corp.
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * 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.axis2.jaxws.provider;
018:
019:        import javax.xml.ws.Service;
020:        import javax.xml.namespace.QName;
021:        import javax.xml.ws.soap.SOAPBinding;
022:        import javax.xml.ws.BindingProvider;
023:        import javax.xml.soap.SOAPMessage;
024:        import junit.framework.TestCase;
025:
026:        /**
027:         * Tests Dispatch<SOAPMessage> client and a Provider<SOAPMessage> service
028:         * with mustUnderstand attribute header.
029:         */
030:        public class SoapMessageMUProviderTests extends TestCase {
031:            public static final QName serviceName = new QName(
032:                    "http://ws.apache.org/axis2",
033:                    "SoapMessageMUProviderService");
034:            public static final QName portName = new QName(
035:                    "http://ws.apache.org/axis2",
036:                    "SimpleProviderServiceSOAP11port0");
037:            public static final String endpointUrl = "http://localhost:8080/axis2/services/SoapMessageMUProviderService";
038:
039:            public static final String bindingID = SOAPBinding.SOAP11HTTP_BINDING;
040:            public static final Service.Mode mode = Service.Mode.MESSAGE;
041:
042:            protected void setUp() throws Exception {
043:                super .setUp();
044:            }
045:
046:            protected void tearDown() throws Exception {
047:                super .tearDown();
048:            }
049:
050:            public SoapMessageMUProviderTests(String name) {
051:                super (name);
052:            }
053:
054:            /**
055:             * Test soap message with no MU headers
056:             */
057:            public void testNoMustUnderstandHeaders() {
058:                System.out.println("testNoMustUnderstandHeaders");
059:                // create a service
060:                Service svc = Service.create(serviceName);
061:                svc.addPort(portName, bindingID, endpointUrl);
062:
063:                javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
064:                dispatch = svc
065:                        .createDispatch(portName, SOAPMessage.class, mode);
066:
067:                ((BindingProvider) dispatch).getRequestContext().put(
068:                        BindingProvider.SOAPACTION_USE_PROPERTY, true);
069:                ((BindingProvider) dispatch).getRequestContext().put(
070:                        BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
071:
072:                SOAPMessage message = AttachmentUtil
073:                        .toSOAPMessage(AttachmentUtil.msgEnvPlain);
074:
075:                try {
076:                    SOAPMessage response = dispatch.invoke(message);
077:
078:                    String string = AttachmentUtil.toString(response);
079:                    assertTrue(string
080:                            .equalsIgnoreCase(AttachmentUtil.XML_HEADER
081:                                    + AttachmentUtil.msgEnvPlain));
082:                } catch (Exception e) {
083:                    fail("Unexpected Exception: " + e.getMessage());
084:                }
085:            }
086:
087:            /**
088:             * Test the mustUnderstand soap header attribute on the client's
089:             * outbound soap message for headers that are not understood.  Should cause an 
090:             * exception.
091:             */
092:            public void testClientRequestNotUnderstoodHeaders() {
093:                System.out.println("testClientRequestNotUnderstoodHeaders");
094:                // create a service
095:                Service svc = Service.create(serviceName);
096:                svc.addPort(portName, bindingID, endpointUrl);
097:
098:                javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
099:                dispatch = svc
100:                        .createDispatch(portName, SOAPMessage.class, mode);
101:
102:                //force SOAPAction to match with wsdl action                        
103:                ((BindingProvider) dispatch).getRequestContext().put(
104:                        BindingProvider.SOAPACTION_USE_PROPERTY, true);
105:                ((BindingProvider) dispatch).getRequestContext().put(
106:                        BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
107:
108:                SOAPMessage message = AttachmentUtil
109:                        .toSOAPMessage(AttachmentUtil.msgEnvMU);
110:
111:                try {
112:                    dispatch.invoke(message);
113:                    fail("Should have received fault for not understood headers on request");
114:                } catch (Exception e) {
115:                    // Expected path
116:                }
117:            }
118:
119:            /**
120:             * Test the mustUnderstand soap header attribute on the server's
121:             * outbound soap message (i.e. the inbound response to the client) for headers that
122:             * are not understood.  Should cause an exception.
123:             */
124:            public void testClientResponseNotUnderstoodHeaders() {
125:                System.out.println("testClientResponseNotUnderstoodHeaders");
126:                // create a service
127:                Service svc = Service.create(serviceName);
128:                svc.addPort(portName, bindingID, endpointUrl);
129:
130:                javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
131:                dispatch = svc
132:                        .createDispatch(portName, SOAPMessage.class, mode);
133:
134:                //force SOAPAction to match with wsdl action                        
135:                ((BindingProvider) dispatch).getRequestContext().put(
136:                        BindingProvider.SOAPACTION_USE_PROPERTY, true);
137:                ((BindingProvider) dispatch).getRequestContext().put(
138:                        BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
139:
140:                SOAPMessage message = AttachmentUtil
141:                        .toSOAPMessage(AttachmentUtil.msgEnv);
142:
143:                try {
144:                    dispatch.invoke(message);
145:                    fail("Should have received fault for not understood headers on response");
146:                } catch (Exception e) {
147:                    // Expected path
148:                }
149:            }
150:
151:            /**
152:             * Test the mustUnderstand soap header attribute on the client's
153:             * outbound soap message for headers that should be understood.  Should not cause an 
154:             * exception.
155:             */
156:            public void testClientRequestUnderstoodHeaders() {
157:                System.out.println("testClientRequestUnderstoodHeaders");
158:                // create a service
159:                Service svc = Service.create(serviceName);
160:                svc.addPort(portName, bindingID, endpointUrl);
161:
162:                javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
163:                dispatch = svc
164:                        .createDispatch(portName, SOAPMessage.class, mode);
165:
166:                //force SOAPAction to match with wsdl action                        
167:                ((BindingProvider) dispatch).getRequestContext().put(
168:                        BindingProvider.SOAPACTION_USE_PROPERTY, true);
169:                ((BindingProvider) dispatch).getRequestContext().put(
170:                        BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
171:
172:                SOAPMessage message = AttachmentUtil
173:                        .toSOAPMessage(AttachmentUtil.msgEnvMU_understood);
174:
175:                try {
176:                    dispatch.invoke(message);
177:                } catch (Exception e) {
178:                    fail("Should not have received fault for headers that were understood.  "
179:                            + e.getMessage());
180:                }
181:            }
182:
183:            /**
184:             * Test the mustUnderstand soap header attribute on the server's
185:             * outbound soap message (i.e. the inbound response to the client) for headers that
186:             * are understood.  Should not cause an exception.
187:             */
188:            public void testClientResponseUnderstoodHeaders() {
189:                System.out.println("testClientResponseUnderstoodHeaders");
190:                // create a service
191:                Service svc = Service.create(serviceName);
192:                svc.addPort(portName, bindingID, endpointUrl);
193:
194:                javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
195:                dispatch = svc
196:                        .createDispatch(portName, SOAPMessage.class, mode);
197:
198:                //force SOAPAction to match with wsdl action                        
199:                ((BindingProvider) dispatch).getRequestContext().put(
200:                        BindingProvider.SOAPACTION_USE_PROPERTY, true);
201:                ((BindingProvider) dispatch).getRequestContext().put(
202:                        BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
203:
204:                SOAPMessage message = AttachmentUtil
205:                        .toSOAPMessage(AttachmentUtil.msgEnv_understood);
206:
207:                try {
208:                    dispatch.invoke(message);
209:                } catch (Exception e) {
210:                    fail("Should not have received fault for headers that were understood.  "
211:                            + e.getMessage());
212:                }
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.