Debian Codegraph @

test/wsdl/soap12/additional/WhiteMesaSoap12AddTestSvcTestCase.java

raw
1 /**
2 * WhiteMesaSoap12AddTestSvcTestCase.java
3 *
4 * This file was auto-generated from WSDL
5 * by the Apache Axis WSDL2Java emitter.
6 */
7
8 package test.wsdl.soap12.additional;
9
10 import org.apache.axis.AxisFault;
11 import org.apache.axis.Constants;
12 import org.apache.axis.utils.XMLUtils;
13 import org.apache.axis.client.Call;
14 import org.apache.axis.encoding.ser.BeanDeserializerFactory;
15 import org.apache.axis.encoding.ser.BeanSerializerFactory;
16 import org.apache.axis.constants.Style;
17 import org.apache.axis.constants.Use;
18 import org.apache.axis.message.*;
19 import org.apache.axis.soap.SOAP12Constants;
20 import org.apache.axis.soap.SOAPConstants;
21 import org.w3c.dom.Document;
22 import org.w3c.dom.NodeList;
23 import org.w3c.dom.Node;
24 import org.w3c.dom.Element;
25 import test.wsdl.soap12.additional.xsd.SOAPStruct;
26
27 import javax.xml.namespace.QName;
28 import javax.xml.rpc.ParameterMode;
29 import java.util.Vector;
30 import java.net.URL;
31
32 /**
33 * Additional SOAP 1.2 tests.
34 *
35 * For details, see:
36 *
37 * http://www.w3.org/2000/xp/Group/2/03/soap1.2implementation.html#addtests
38 *
39 * Auto-generated from WhiteMesa's WSDL, with additional coding by:
40 * @author Davanum Srinivas ([email protected])
41 * @author Glen Daniels ([email protected])
42 */
43 public class WhiteMesaSoap12AddTestSvcTestCase extends junit.framework.TestCase {
44 public static final String STRING_VAL = "SOAP 1.2 is cool!";
45 public static final float FLOAT_VAL = 3.14F;
46 public static final Float FLOAT_OBJVAL = new Float(FLOAT_VAL);
47 public static final int INT_VAL = 69;
48 public static final Integer INT_OBJVAL = new Integer(INT_VAL);
49
50 public final String TEST_NS = "http://soapinterop.org/";
51 public final QName ECHO_STRING_QNAME = new QName(TEST_NS, "echoString");
52
53 // Endpoints
54 // TODO : Shouldn't be hardcoded!
55 // public static final String HOST = "http://localhost:8080";
56 public static String HOST = "http://www.whitemesa.net";
57 public static String RPC_ENDPOINT = HOST + "/soap12/add-test-rpc";
58 public static String DOC_ENDPOINT = HOST + "/soap12/add-test-doc";
59 public static String GET_DOC_ENDPOINT = HOST + "/soap12/add-test-doc/getTime";
60 public static String GET_RPC_ENDPOINT = HOST + "/soap12/add-test-rpc/getTime";
61 public static String DOC_INT_ENDPOINT = HOST + "/soap12/add-test-doc-int";
62 public static String DOC_INT_UC_ENDPOINT = HOST + "/soap12/add-test-doc-int-uc";
63 private QName SOAPSTRUCT_QNAME = new QName("http://example.org/ts-tests/xsd", "SOAPStruct");
64
65 static String configFile = null;
66
67 public static void main(String[] args) throws Exception {
68 // If we have an argument, it's a configuration file.
69 if (args.length > 0) {
70 configFile = args[0];
71 }
72 WhiteMesaSoap12AddTestSvcTestCase tester = new WhiteMesaSoap12AddTestSvcTestCase("testXMLP5");
73 tester.setUp();
74 tester.testXMLP19();
75 System.out.println("Done.");
76 // junit.textui.TestRunner.run(WhiteMesaSoap12AddTestSvcTestCase.class);
77 }
78
79 public WhiteMesaSoap12AddTestSvcTestCase(java.lang.String name) {
80 super(name);
81 }
82
83 public void testSoap12AddTestDocUpperPortWSDL() throws Exception {
84 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
85 java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocUpperPortAddress() + "?WSDL");
86 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
87 assertTrue(service != null);
88 }
89
90 public void testSoap12AddTestRpcPortWSDL() throws Exception {
91 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
92 java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestRpcPortAddress() + "?WSDL");
93 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
94 assertTrue(service != null);
95 }
96
97 public void testSoap12AddTestDocIntermediaryPortWSDL() throws Exception {
98 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
99 java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocIntermediaryPortAddress() + "?WSDL");
100 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
101 assertTrue(service != null);
102 }
103
104 public void testSoap12AddTestDocPortWSDL() throws Exception {
105 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
106 java.net.URL url = new java.net.URL(new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocPortAddress() + "?WSDL");
107 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getServiceName());
108 assertTrue(service != null);
109 }
110
111 protected void setUp() throws Exception {
112 if (configFile == null) {
113 configFile = System.getProperty("configFile");
114 }
115
116 if (configFile == null) {
117 return;
118 }
119
120 Document doc = XMLUtils.newDocument(configFile);
121 NodeList nl = doc.getDocumentElement().getChildNodes();
122 for (int i = 0; i < nl.getLength(); i++) {
123 Node node = nl.item(i);
124 if (!(node instanceof Element))
125 continue;
126 Element el = (Element) node;
127 String tag = el.getLocalName();
128 String data = XMLUtils.getChildCharacterData(el);
129 if ("host".equals(tag)) {
130 HOST = data;
131 RPC_ENDPOINT = HOST + "/soap12/add-test-rpc";
132 DOC_ENDPOINT = HOST + "/soap12/add-test-doc";
133 GET_DOC_ENDPOINT = HOST + "/soap12/add-test-doc/getTime";
134 GET_RPC_ENDPOINT = HOST + "/soap12/add-test-rpc/getTime";
135 DOC_INT_ENDPOINT = HOST + "/soap12/add-test-doc-int";
136 DOC_INT_UC_ENDPOINT = HOST + "/soap12/add-test-doc-int-uc";
137 } else if ("rpcEndpoint".equals(tag)) {
138 RPC_ENDPOINT = data;
139 } else if ("docEndpoint".equals(tag)) {
140 DOC_ENDPOINT = data;
141 } else if ("getRpcEndpoint".equals(tag)) {
142 GET_RPC_ENDPOINT = data;
143 } else if ("getDocEndpoint".equals(tag)) {
144 GET_DOC_ENDPOINT = data;
145 } else if ("docIntEndpoint".equals(tag)) {
146 DOC_INT_ENDPOINT = data;
147 } else if ("docIntUcEndpoint".equals(tag)) {
148 DOC_INT_UC_ENDPOINT = data;
149 }
150 }
151 }
152
153 /**
154 * Test xmlp-1 - call echoString with no arguments (even though it expects
155 * one). Confirm bad arguments fault from endpoint.
156 *
157 * @throws Exception
158 */
159 public void testXMLP1() throws Exception {
160 Call call = new Call(RPC_ENDPOINT);
161 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
162 try {
163 call.invoke(ECHO_STRING_QNAME, null);
164 } catch (AxisFault fault) {
165 assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
166 QName [] subCodes = fault.getFaultSubCodes();
167 assertNotNull(subCodes);
168 assertEquals(1, subCodes.length);
169 assertEquals(Constants.FAULT_SUBCODE_BADARGS, subCodes[0]);
170 return;
171 }
172 fail("Didn't catch expected fault");
173 }
174
175 /**
176 * Test xmlp-2, using the GET webmethod.
177 *
178 * @throws Exception
179 */
180 public void testXMLP2() throws Exception {
181 Call call = new Call(GET_DOC_ENDPOINT);
182 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
183 call.setProperty(SOAP12Constants.PROP_WEBMETHOD, "GET");
184 call.setOperationStyle(Style.DOCUMENT);
185 call.setOperationUse(Use.LITERAL);
186 call.invoke();
187 SOAPEnvelope env = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
188 Object result = env.getFirstBody().getValueAsType(Constants.XSD_TIME);
189 assertEquals(org.apache.axis.types.Time.class, result.getClass());
190 // Suppose we could check the actual time here too, but we aren't
191 // gonna for now.
192 }
193
194 /**
195 * Test xmlp-3, using the GET webmethod and RPC mode (i.e. deal with
196 * the rpc:result element).
197 *
198 * @throws Exception
199 */
200 public void testXMLP3() throws Exception {
201 Call call = new Call(GET_RPC_ENDPOINT);
202 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
203 call.setProperty(SOAP12Constants.PROP_WEBMETHOD, "GET");
204 call.setOperationStyle(Style.RPC);
205 call.setReturnType(Constants.XSD_TIME);
206 Object ret = call.invoke("", new Object [] {});
207 assertEquals(org.apache.axis.types.Time.class, ret.getClass());
208 // Suppose we could check the actual time here too, but we aren't
209 // gonna for now.
210 }
211
212 public void testXMLP4() throws Exception {
213 Call call = new Call(RPC_ENDPOINT);
214 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
215 call.registerTypeMapping(SOAPStruct.class, SOAPSTRUCT_QNAME,
216 new BeanSerializerFactory(SOAPStruct.class, SOAPSTRUCT_QNAME),
217 new BeanDeserializerFactory(SOAPStruct.class, SOAPSTRUCT_QNAME));
218 call.addParameter(new QName("", "inputFloat"),
219 Constants.XSD_FLOAT, ParameterMode.IN);
220 call.addParameter(new QName("", "inputInteger"),
221 Constants.XSD_INT, ParameterMode.IN);
222 call.addParameter(new QName("", "inputString"),
223 Constants.XSD_STRING, ParameterMode.IN);
224 call.setReturnType(SOAPSTRUCT_QNAME);
225 SOAPStruct ret = (SOAPStruct)call.invoke(
226 new QName(TEST_NS, "echoSimpleTypesAsStruct"),
227 new Object [] {
228 new Float(FLOAT_VAL),
229 new Integer(INT_VAL),
230 STRING_VAL
231 });
232 assertEquals(STRING_VAL, ret.getVarString());
233 assertEquals(FLOAT_VAL, ret.getVarFloat(), 0.0004F);
234 assertEquals(INT_VAL, ret.getVarInt());
235 }
236
237 public void testXMLP5() throws Exception {
238 Call call = new Call(RPC_ENDPOINT);
239 try {
240 call.invoke(new QName(TEST_NS, "echoVoid"), null);
241 } catch (AxisFault fault) {
242 // Got the expected Fault - make sure it looks right
243 assertEquals(Constants.FAULT_VERSIONMISMATCH, fault.getFaultCode());
244 return;
245 }
246 fail("Didn't catch expected fault");
247 }
248
249 public void testXMLP6() throws Exception {
250 Call call = new Call(RPC_ENDPOINT);
251 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
252 SOAPHeaderElement unknownHeader =
253 new SOAPHeaderElement("http://example.org",
254 "unknown",
255 "Nobody understands me!");
256 unknownHeader.setMustUnderstand(true);
257 call.addHeader(unknownHeader);
258 try {
259 call.invoke(new QName(TEST_NS, "echoVoid"), null);
260 } catch (AxisFault fault) {
261 // Got the expected Fault - make sure it looks right
262 assertEquals(Constants.FAULT_SOAP12_MUSTUNDERSTAND,
263 fault.getFaultCode());
264 return;
265 }
266 fail("Didn't catch expected fault");
267 }
268
269 public void testXMLP7() throws Exception {
270 URL url = new URL(DOC_ENDPOINT);
271 test.wsdl.soap12.additional.Soap12AddTestDocBindingStub binding;
272 try {
273 binding = (test.wsdl.soap12.additional.Soap12AddTestDocBindingStub)
274 new test.wsdl.soap12.additional.WhiteMesaSoap12AddTestSvcLocator().getSoap12AddTestDocPort(url);
275 }
276 catch (javax.xml.rpc.ServiceException jre) {
277 if(jre.getLinkedCause()!=null)
278 jre.getLinkedCause().printStackTrace();
279 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
280 }
281 assertNotNull("binding is null", binding);
282
283 // Time out after a minute
284 binding.setTimeout(60000);
285
286 // Test operation
287 try {
288 binding.echoSenderFault(STRING_VAL);
289 } catch (java.rmi.RemoteException e) {
290 if (e instanceof AxisFault) {
291 AxisFault af = (AxisFault)e;
292 assertEquals(Constants.FAULT_SOAP12_SENDER,
293 af.getFaultCode());
294 return; // success
295 }
296 }
297
298 fail("Should have received sender fault!");
299 }
300
301 public void testXMLP8() throws Exception {
302 Call call = new Call(DOC_ENDPOINT);
303 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
304 QName qname = new QName(TEST_NS, "echoReceiverFault");
305 try {
306 call.invoke(qname, null);
307 } catch (AxisFault af) {
308 assertEquals(Constants.FAULT_SOAP12_RECEIVER,
309 af.getFaultCode());
310 return; // success
311 }
312
313 fail("Should have received receiver fault!");
314 }
315
316 /**
317 * Test xmlp-9 : do an "echoString" call with a bad (unknown) encoding
318 * style on the argument. Confirm Sender fault from endpoint.
319 *
320 * @throws Exception
321 */
322 public void testXMLP9() throws Exception {
323 Call call = new Call(RPC_ENDPOINT);
324 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
325 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
326 SOAPBodyElement body = new SOAPBodyElement(new PrefixedQName(TEST_NS, "echoString", "ns"));
327 reqEnv.addBodyElement(body);
328 MessageElement arg = new MessageElement("", "inputString");
329 arg.setEncodingStyle("http://this-is-a-bad-encoding-style");
330 body.addChild(arg);
331 try {
332 call.invoke(reqEnv);
333 } catch (AxisFault fault) {
334 assertEquals(Constants.FAULT_SOAP12_DATAENCODINGUNKNOWN, fault.getFaultCode());
335 return;
336 }
337 fail("Didn't catch expected fault");
338 }
339
340 /**
341 * Test xmlp-10 : reply with the schema types of the arguments, in order
342 */
343 // public void testXMLP10() throws Exception {
344 // Call call = new Call(RPC_ENDPOINT);
345 // call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
346 // SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
347 // SOAPBodyElement body = new SOAPBodyElement(
348 // new PrefixedQName(TEST_NS,
349 // "echoSimpleTypesAsStructOfSchemaTypes", "ns"));
350 // reqEnv.addBodyElement(body);
351 // MessageElement arg = new MessageElement("", "input1");
352 // arg.setObjectValue(new Integer(5));
353 // body.addChild(arg);
354 // arg = new MessageElement("", "input2");
355 // arg.setObjectValue(new Float(5.5F));
356 // body.addChild(arg);
357 // arg = new MessageElement("", "input3");
358 // arg.setObjectValue("hi there");
359 // body.addChild(arg);
360 // arg = new MessageElement("", "input4");
361 // Text text = new Text("untyped");
362 // arg.addChild(text);
363 // body.addChild(arg);
364 // call.invoke(reqEnv);
365 // }
366
367 /**
368 * Test xmlp-11 : send a string where an integer is expected, confirm
369 * BadArguments fault.
370 *
371 * @throws Exception
372 */
373 public void testXMLP11() throws Exception {
374 Call call = new Call(RPC_ENDPOINT);
375 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
376 call.setProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);
377 try {
378 call.invoke(new QName(TEST_NS, "echoInteger"),
379 new Object [] { new RPCParam("inputInteger",
380 "ceci n'est pas un int")
381 }
382 );
383 } catch (AxisFault fault) {
384 assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
385 QName [] subCodes = fault.getFaultSubCodes();
386 assertNotNull(subCodes);
387 assertEquals(1, subCodes.length);
388 assertEquals(Constants.FAULT_SUBCODE_BADARGS, subCodes[0]);
389 return;
390 }
391 fail("Didn't catch expected fault");
392 }
393
394 /**
395 * Test xmlp-12 : unknown method call to RPC endpoint. Confirm
396 * "ProcedureNotPresent" subcode of "Sender" fault.
397 *
398 * @throws Exception
399 */
400 public void testXMLP12() throws Exception {
401 Call call = new Call(RPC_ENDPOINT);
402 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
403 call.addParameter(new QName("inputInteger"), Constants.XSD_INT, ParameterMode.IN);
404 try {
405 call.invoke(new QName(TEST_NS, "unknownFreakyMethod"), new Object [] { new Integer(5) });
406 } catch (AxisFault fault) {
407 assertEquals(Constants.FAULT_SOAP12_SENDER, fault.getFaultCode());
408 QName [] subCodes = fault.getFaultSubCodes();
409 assertNotNull(subCodes);
410 assertEquals(1, subCodes.length);
411 assertEquals(Constants.FAULT_SUBCODE_PROC_NOT_PRESENT, subCodes[0]);
412 return;
413 }
414 fail("Didn't catch expected fault");
415 }
416
417 /**
418 * Test xmlp-13 : doc/lit echoString which sends back the original
419 * message via a transparent "forwarding intermediary"
420 *
421 */
422 public void testXMLP13() throws Exception {
423 String ARG = "i FeEL sTrAnGEly CAsEd (but I like it)";
424 Call call = new Call(DOC_INT_ENDPOINT);
425 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
426 call.setOperationStyle(Style.WRAPPED);
427 call.addParameter(new QName(TEST_NS, "inputString"),
428 Constants.XSD_STRING, ParameterMode.IN);
429 call.setReturnType(Constants.XSD_STRING);
430
431 String ret = (String)call.invoke(ECHO_STRING_QNAME, new Object [] { ARG });
432 assertEquals("Return didn't match argument", ARG, ret);
433 }
434
435 /**
436 * Test xmlp-14 : doc/lit echoString which sends back the original
437 * message via an "active intermediary" (translating the string
438 * to uppercase)
439 *
440 */
441 public void testXMLP14() throws Exception {
442 String ARG = "i FeEL sTrAnGEly CAsEd (and dream of UPPER)";
443 Call call = new Call(DOC_INT_UC_ENDPOINT);
444 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
445 call.setOperationStyle(Style.WRAPPED);
446 call.addParameter(new QName(TEST_NS, "inputString"),
447 Constants.XSD_STRING, ParameterMode.IN);
448 call.setReturnType(Constants.XSD_STRING);
449
450 String ret = (String)call.invoke(ECHO_STRING_QNAME, new Object [] { ARG });
451 assertEquals("Return wasn't uppercased argument", ARG.toUpperCase(), ret);
452 }
453
454 public void testXMLP15() throws Exception {
455 String HEADER_VAL = "I'm going to be discarded!";
456 String HEADER_NS = "http://test-xmlp-15";
457 String HEADER_NAME = "unknown";
458
459 Call call = new Call(DOC_INT_ENDPOINT);
460 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
461 call.setOperationStyle(Style.WRAPPED);
462 call.setOperationUse(Use.LITERAL);
463
464 SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
465 header.setRole(Constants.URI_SOAP12_NEXT_ROLE);
466 header.setObjectValue(HEADER_VAL);
467 call.addHeader(header);
468
469 call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
470
471 SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
472
473 // Confirm we got no headers back
474 Vector headers = respEnv.getHeaders();
475 assertTrue("Headers Vector wasn't empty", headers.isEmpty());
476 }
477
478 public void testXMLP16() throws Exception {
479 String HEADER_VAL = "I'm going all the way through!";
480 String HEADER_NS = "http://test-xmlp-16";
481 String HEADER_NAME = "unknown";
482 QName HEADER_QNAME = new QName(HEADER_NS, HEADER_NAME);
483
484 Call call = new Call(DOC_INT_ENDPOINT);
485 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
486
487 SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
488 header.setRole(Constants.URI_SOAP12_NONE_ROLE);
489 header.setObjectValue(HEADER_VAL);
490 call.addHeader(header);
491
492 call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
493
494 SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
495
496 // Confirm we got our header back
497 Vector headers = respEnv.getHeaders();
498 assertEquals(1, headers.size());
499 SOAPHeaderElement respHeader = (SOAPHeaderElement)headers.get(0);
500 assertEquals(Constants.URI_SOAP12_NONE_ROLE, respHeader.getRole());
501 assertEquals(HEADER_QNAME, respHeader.getQName());
502 assertEquals(HEADER_VAL, respHeader.getValue());
503 }
504
505 public void testXMLP17() throws Exception {
506 String HEADER_VAL = "I'm going all the way through!";
507 String HEADER_NS = "http://test-xmlp-17";
508 String HEADER_NAME = "seekrit";
509 QName HEADER_QNAME = new QName(HEADER_NS, HEADER_NAME);
510
511 Call call = new Call(DOC_INT_ENDPOINT);
512 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
513
514 SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
515 header.setRole(Constants.URI_SOAP12_ULTIMATE_ROLE);
516 header.setObjectValue(HEADER_VAL);
517 call.addHeader(header);
518
519 call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
520
521 SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
522
523 // Confirm we got a single header back, targeted at the ultimate
524 // receiver
525 Vector headers = respEnv.getHeaders();
526 assertEquals(1, headers.size());
527 SOAPHeaderElement respHeader = (SOAPHeaderElement)headers.get(0);
528 assertEquals(Constants.URI_SOAP12_ULTIMATE_ROLE, respHeader.getRole());
529 assertEquals(HEADER_QNAME, respHeader.getQName());
530 assertEquals(HEADER_VAL, respHeader.getValue());
531 }
532
533 public void testXMLP18() throws Exception {
534 String HEADER_VAL = "I'm going all the way through!";
535 String HEADER_NS = "http://test-xmlp-17";
536 String HEADER_NAME = "seekrit";
537 QName HEADER_QNAME = new QName(HEADER_NS, HEADER_NAME);
538
539 Call call = new Call(DOC_INT_ENDPOINT);
540 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
541
542 SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
543 header.setRole(Constants.URI_SOAP12_NEXT_ROLE);
544 header.setRelay(true);
545 header.setObjectValue(HEADER_VAL);
546 call.addHeader(header);
547
548 call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
549
550 SOAPEnvelope respEnv = call.getMessageContext().getResponseMessage().getSOAPEnvelope();
551
552 // Confirm we got a single header back, targeted at the ultimate
553 // receiver
554 Vector headers = respEnv.getHeaders();
555 assertEquals(1, headers.size());
556 SOAPHeaderElement respHeader = (SOAPHeaderElement)headers.get(0);
557 assertEquals(Constants.URI_SOAP12_NEXT_ROLE, respHeader.getRole());
558 assertTrue(respHeader.getRelay());
559 assertEquals(HEADER_QNAME, respHeader.getQName());
560 assertEquals(HEADER_VAL, respHeader.getValue());
561 }
562
563 public void testXMLP19() throws Exception {
564 String HEADER_VAL = "I'm going to generate a fault!";
565 String HEADER_NS = "http://test-xmlp-17";
566 String HEADER_NAME = "seekrit";
567
568 Call call = new Call(DOC_INT_ENDPOINT);
569 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
570
571 SOAPHeaderElement header = new SOAPHeaderElement(HEADER_NS, HEADER_NAME);
572 header.setRole(Constants.URI_SOAP12_NEXT_ROLE);
573 header.setMustUnderstand(true);
574 header.setObjectValue(HEADER_VAL);
575 call.addHeader(header);
576
577 try {
578 call.invoke(ECHO_STRING_QNAME, new Object [] { "body string" });
579 } catch (AxisFault fault) {
580 // Got the expected Fault - make sure it looks right
581 assertEquals(Constants.FAULT_SOAP12_MUSTUNDERSTAND,
582 fault.getFaultCode());
583 return;
584 }
585
586 fail("Didn't catch expected fault");
587 }
588 }