1 7 8 package test.wsdl.soap12.assertion; 9 10 import org.apache.axis.message.SOAPHeaderElement; 11 import org.apache.axis.message.SOAPEnvelope; 12 import org.apache.axis.Constants; 13 import org.apache.axis.MessageContext; 14 import org.apache.axis.AxisFault; 15 import org.apache.axis.soap.SOAPConstants; 16 import org.apache.axis.constants.Style; 17 import org.apache.axis.client.Call; 18 import org.apache.axis.client.Service; 19 20 import java.util.Arrays ; 21 import java.util.TimeZone ; 22 import java.util.Calendar ; 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 26 public class WhiteMesaSoap12TestSvcTestCase extends junit.framework.TestCase { 27 public final String TEST_NS = "http://example.org/ts-tests"; 28 public final String DOC_ENDPOINT = "http://www.whitemesa.net/soap12/test-doc"; 29 public final String INTERMEDIARY_ENDPOINT = "http://www.whitemesa.net/soap12/test-intermediary"; 30 public final String ROLE_A = "http://example.org/ts-tests/A"; 31 public final String ROLE_B = "http://example.org/ts-tests/B"; 32 public final String ROLE_C = "http://example.org/ts-tests/C"; 33 34 public WhiteMesaSoap12TestSvcTestCase(java.lang.String name) { 35 super(name); 36 } 37 38 public void testSoap12TestDocPortWSDL() throws Exception { 39 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 40 java.net.URL url = new java.net.URL (new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestDocPortAddress() + "?WSDL"); 41 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getServiceName()); 42 assertTrue(service != null); 43 } 44 45 public void testSoap12TestRpcPortWSDL() throws Exception { 46 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 47 java.net.URL url = new java.net.URL (new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPortAddress() + "?WSDL"); 48 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getServiceName()); 49 assertTrue(service != null); 50 } 51 52 public void test1Soap12TestRpcPortReturnVoid() throws Exception { 53 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 54 try { 55 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 56 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 57 } 58 catch (javax.xml.rpc.ServiceException jre) { 59 if(jre.getLinkedCause()!=null) 60 jre.getLinkedCause().printStackTrace(); 61 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 62 } 63 assertNotNull("binding is null", binding); 64 65 binding.setTimeout(60000); 67 68 binding.returnVoid(); 70 } 72 73 public void test2Soap12TestRpcPortEchoStruct() throws Exception { 74 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 75 try { 76 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 77 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 78 } 79 catch (javax.xml.rpc.ServiceException jre) { 80 if(jre.getLinkedCause()!=null) 81 jre.getLinkedCause().printStackTrace(); 82 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 83 } 84 assertNotNull("binding is null", binding); 85 86 binding.setTimeout(60000); 88 89 test.wsdl.soap12.assertion.xsd.SOAPStruct input = new test.wsdl.soap12.assertion.xsd.SOAPStruct(); 90 input.setVarFloat(-5); 91 input.setVarInt(10); 92 input.setVarString("EchoStruct"); 93 94 test.wsdl.soap12.assertion.xsd.SOAPStruct output = null; 96 output = binding.echoStruct(input); 97 assertEquals(input, output); 99 } 100 101 public void test3Soap12TestRpcPortEchoStructArray() throws Exception { 102 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 103 try { 104 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 105 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 106 } 107 catch (javax.xml.rpc.ServiceException jre) { 108 if(jre.getLinkedCause()!=null) 109 jre.getLinkedCause().printStackTrace(); 110 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 111 } 112 assertNotNull("binding is null", binding); 113 114 binding.setTimeout(60000); 116 117 test.wsdl.soap12.assertion.xsd.SOAPStruct[] input = new test.wsdl.soap12.assertion.xsd.SOAPStruct[1]; 118 input[0] = new test.wsdl.soap12.assertion.xsd.SOAPStruct(); 119 input[0].setVarFloat(-5); 120 input[0].setVarInt(10); 121 input[0].setVarString("EchoStruct"); 122 test.wsdl.soap12.assertion.xsd.SOAPStruct[] output = null; 124 output = binding.echoStructArray(input); 125 assertTrue(Arrays.equals(input,output)); 127 } 128 129 public void test4Soap12TestRpcPortEchoStructAsSimpleTypes() throws Exception { 130 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 131 try { 132 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 133 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 134 } 135 catch (javax.xml.rpc.ServiceException jre) { 136 if(jre.getLinkedCause()!=null) 137 jre.getLinkedCause().printStackTrace(); 138 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 139 } 140 assertNotNull("binding is null", binding); 141 142 binding.setTimeout(60000); 144 145 test.wsdl.soap12.assertion.xsd.SOAPStruct input = new test.wsdl.soap12.assertion.xsd.SOAPStruct(); 146 input.setVarFloat(-5); 147 input.setVarInt(10); 148 input.setVarString("EchoStructAsSimpleTypes"); 149 150 javax.xml.rpc.holders.StringHolder out1 = new javax.xml.rpc.holders.StringHolder (); 151 javax.xml.rpc.holders.IntHolder out2 = new javax.xml.rpc.holders.IntHolder (); 152 javax.xml.rpc.holders.FloatHolder out3 = new javax.xml.rpc.holders.FloatHolder (); 153 154 binding.echoStructAsSimpleTypes(input, out1, out2, out3); 156 assertEquals(out1.value, input.getVarString()); 158 assertEquals(out2.value, input.getVarInt()); 159 assertTrue(out3.value == input.getVarFloat()); 160 } 161 162 public void test5Soap12TestRpcPortEchoSimpleTypesAsStruct() throws Exception { 163 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 164 try { 165 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 166 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 167 } 168 catch (javax.xml.rpc.ServiceException jre) { 169 if(jre.getLinkedCause()!=null) 170 jre.getLinkedCause().printStackTrace(); 171 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 172 } 173 assertNotNull("binding is null", binding); 174 175 binding.setTimeout(60000); 177 178 String input1 = new String ("EchoSimpleTypesAsStruct"); 179 int input2 = 50; 180 float input3 = 45.5F; 181 test.wsdl.soap12.assertion.xsd.SOAPStruct output = null; 183 output = binding.echoSimpleTypesAsStruct(input1, input2, input3); 184 185 assertEquals(input1, output.getVarString()); 187 assertEquals(input2, output.getVarInt()); 188 assertTrue(input3 == output.getVarFloat()); 189 } 190 191 public void test6Soap12TestRpcPortEchoNestedStruct() throws Exception { 192 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 193 try { 194 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 195 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 196 } 197 catch (javax.xml.rpc.ServiceException jre) { 198 if(jre.getLinkedCause()!=null) 199 jre.getLinkedCause().printStackTrace(); 200 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 201 } 202 assertNotNull("binding is null", binding); 203 204 binding.setTimeout(60000); 206 207 test.wsdl.soap12.assertion.xsd.SOAPStructStruct input = new test.wsdl.soap12.assertion.xsd.SOAPStructStruct(); 208 input.setVarFloat(-5); 209 input.setVarInt(10); 210 input.setVarString("EchoNestedStruct1"); 211 212 test.wsdl.soap12.assertion.xsd.SOAPStruct inputInner = new test.wsdl.soap12.assertion.xsd.SOAPStruct(); 213 inputInner.setVarFloat(-5); 214 inputInner.setVarInt(10); 215 inputInner.setVarString("EchoNestedStruct2"); 216 217 input.setVarStruct(inputInner); 218 219 test.wsdl.soap12.assertion.xsd.SOAPStructStruct output = null; 221 output = binding.echoNestedStruct(input); 222 223 assertEquals(input, output); 225 } 226 227 public void test7Soap12TestRpcPortEchoNestedArray() throws Exception { 228 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 229 try { 230 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 231 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 232 } 233 catch (javax.xml.rpc.ServiceException jre) { 234 if(jre.getLinkedCause()!=null) 235 jre.getLinkedCause().printStackTrace(); 236 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 237 } 238 assertNotNull("binding is null", binding); 239 240 binding.setTimeout(60000); 242 243 test.wsdl.soap12.assertion.xsd.SOAPArrayStruct input = new test.wsdl.soap12.assertion.xsd.SOAPArrayStruct(); 244 input.setVarFloat(-5); 245 input.setVarInt(10); 246 input.setVarString("EchoNestedArray1"); 247 input.setVarArray(new String [] {"EchoNestedArray2","EchoNestedArray3","EchoNestedArray4"}); 248 249 } 256 257 public void test8Soap12TestRpcPortEchoFloatArray() throws Exception { 258 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 259 try { 260 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 261 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 262 } 263 catch (javax.xml.rpc.ServiceException jre) { 264 if(jre.getLinkedCause()!=null) 265 jre.getLinkedCause().printStackTrace(); 266 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 267 } 268 assertNotNull("binding is null", binding); 269 270 binding.setTimeout(60000); 272 273 float[] input = new float[] { 274 1.1F, 275 1.2F, 276 1.3F 277 }; 278 279 float[] output = null; 281 output = binding.echoFloatArray(input); 282 283 assertTrue(Arrays.equals(input,output)); 285 } 286 287 public void test9Soap12TestRpcPortEchoStringArray() throws Exception { 288 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 289 try { 290 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 291 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 292 } 293 catch (javax.xml.rpc.ServiceException jre) { 294 if(jre.getLinkedCause()!=null) 295 jre.getLinkedCause().printStackTrace(); 296 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 297 } 298 assertNotNull("binding is null", binding); 299 300 binding.setTimeout(60000); 302 303 String [] input = new String [] { 304 "1.1F", 305 "1.2F", 306 "1.3F" 307 }; 308 java.lang.String [] output = null; 310 output = binding.echoStringArray(input); 311 312 assertTrue(Arrays.equals(input,output)); 314 } 315 316 public void test10Soap12TestRpcPortEchoIntegerArray() throws Exception { 317 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 318 try { 319 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 320 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 321 } 322 catch (javax.xml.rpc.ServiceException jre) { 323 if(jre.getLinkedCause()!=null) 324 jre.getLinkedCause().printStackTrace(); 325 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 326 } 327 assertNotNull("binding is null", binding); 328 329 binding.setTimeout(60000); 331 332 int[] input = new int[] { 333 1, 334 2, 335 3 336 }; 337 int[] output = null; 339 output = binding.echoIntegerArray(input); 340 341 assertTrue(Arrays.equals(input,output)); 343 } 344 345 public void test11Soap12TestRpcPortEchoBase64() throws Exception { 346 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 347 try { 348 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 349 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 350 } 351 catch (javax.xml.rpc.ServiceException jre) { 352 if(jre.getLinkedCause()!=null) 353 jre.getLinkedCause().printStackTrace(); 354 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 355 } 356 assertNotNull("binding is null", binding); 357 358 binding.setTimeout(60000); 360 361 byte[] input = new byte[] {0xC, 0xA, 0xF, 0xE}; 362 363 byte[] output = null; 365 output = binding.echoBase64(input); 366 367 assertTrue(Arrays.equals(input,output)); 369 } 370 371 public void test12Soap12TestRpcPortEchoBoolean() throws Exception { 372 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 373 try { 374 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 375 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 376 } 377 catch (javax.xml.rpc.ServiceException jre) { 378 if(jre.getLinkedCause()!=null) 379 jre.getLinkedCause().printStackTrace(); 380 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 381 } 382 assertNotNull("binding is null", binding); 383 384 binding.setTimeout(60000); 386 387 boolean value = false; 389 value = binding.echoBoolean(true); 390 assertEquals(true, value); 392 } 393 394 public void test13Soap12TestRpcPortEchoDate() throws Exception { 395 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 396 try { 397 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 398 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 399 } 400 catch (javax.xml.rpc.ServiceException jre) { 401 if(jre.getLinkedCause()!=null) 402 jre.getLinkedCause().printStackTrace(); 403 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 404 } 405 assertNotNull("binding is null", binding); 406 407 binding.setTimeout(60000); 409 410 java.util.Calendar input = java.util.Calendar.getInstance(); 411 input.setTimeZone(TimeZone.getTimeZone("GMT")); 412 input.set(Calendar.MILLISECOND, 0); 413 414 java.util.Calendar output = null; 415 output = binding.echoDate(input); 416 output.setTimeZone(TimeZone.getTimeZone("GMT")); 417 assertEquals(input, output); 418 } 419 420 public void test14Soap12TestRpcPortEchoDecimal() throws Exception { 421 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 422 try { 423 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 424 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 425 } 426 catch (javax.xml.rpc.ServiceException jre) { 427 if(jre.getLinkedCause()!=null) 428 jre.getLinkedCause().printStackTrace(); 429 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 430 } 431 assertNotNull("binding is null", binding); 432 433 binding.setTimeout(60000); 435 436 java.math.BigDecimal input = new java.math.BigDecimal (5000); 437 438 java.math.BigDecimal output = null; 440 output = binding.echoDecimal(input); 441 442 assertEquals(input, output); 444 } 445 446 public void test15Soap12TestRpcPortEchoFloat() throws Exception { 447 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 448 try { 449 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 450 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 451 } 452 catch (javax.xml.rpc.ServiceException jre) { 453 if(jre.getLinkedCause()!=null) 454 jre.getLinkedCause().printStackTrace(); 455 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 456 } 457 assertNotNull("binding is null", binding); 458 459 binding.setTimeout(60000); 461 462 float input = -334.5F; 463 float output = 0; 465 output = binding.echoFloat(input); 466 assertTrue(input == output); 468 } 469 470 public void test16Soap12TestRpcPortEchoString() throws Exception { 471 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 472 try { 473 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 474 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 475 } 476 catch (javax.xml.rpc.ServiceException jre) { 477 if(jre.getLinkedCause()!=null) 478 jre.getLinkedCause().printStackTrace(); 479 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 480 } 481 assertNotNull("binding is null", binding); 482 483 binding.setTimeout(60000); 485 486 java.lang.String value = null; 488 value = binding.echoString(new java.lang.String ("EchoString")); 489 490 assertEquals("EchoString", value); 492 } 493 494 public void test17Soap12TestRpcPortCountItems() throws Exception { 495 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 496 try { 497 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 498 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 499 } 500 catch (javax.xml.rpc.ServiceException jre) { 501 if(jre.getLinkedCause()!=null) 502 jre.getLinkedCause().printStackTrace(); 503 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 504 } 505 assertNotNull("binding is null", binding); 506 507 binding.setTimeout(60000); 509 510 int output = -3; 512 output = binding.countItems(new java.lang.String [] {"Life","is","a","box","of","chocolates"}); 513 assertEquals(output, 6); 515 } 516 517 public void test18Soap12TestRpcPortIsNil() throws Exception { 518 test.wsdl.soap12.assertion.Soap12TestRpcBindingStub binding; 519 try { 520 binding = (test.wsdl.soap12.assertion.Soap12TestRpcBindingStub) 521 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestRpcPort(); 522 } 523 catch (javax.xml.rpc.ServiceException jre) { 524 if(jre.getLinkedCause()!=null) 525 jre.getLinkedCause().printStackTrace(); 526 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 527 } 528 assertNotNull("binding is null", binding); 529 530 binding.setTimeout(60000); 532 533 } 540 541 548 protected void testEchoOkHeaderWithEmptyBody(String role) throws Exception { 549 test.wsdl.soap12.assertion.Soap12TestDocBindingStub binding; 550 try { 551 binding = (test.wsdl.soap12.assertion.Soap12TestDocBindingStub) 552 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestDocPort(); 553 } 554 catch (javax.xml.rpc.ServiceException jre) { 555 if(jre.getLinkedCause()!=null) 556 jre.getLinkedCause().printStackTrace(); 557 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 558 } 559 assertNotNull("binding is null", binding); 560 561 binding.setTimeout(60000); 563 564 SOAPHeaderElement header = 566 new SOAPHeaderElement(TEST_NS, "echoOk"); 567 if (role != null) 568 header.setRole(role); 569 header.setObjectValue("this is a test"); 570 binding.setHeader(header); 571 binding.emptyBody(); 572 SOAPHeaderElement respHeader = 574 binding.getHeader(TEST_NS, 575 "responseOk"); 576 assertNotNull("Missing response header", respHeader); 577 assertEquals("this is a test", respHeader.getValue()); 578 } 579 580 585 public void testT1() throws Exception { 586 testEchoOkHeaderWithEmptyBody(Constants.URI_SOAP12_NEXT_ROLE); 587 } 588 589 594 public void testT2() throws Exception { 595 testEchoOkHeaderWithEmptyBody("http://example.org/ts-tests/C"); 596 } 597 598 603 public void testT3() throws Exception { 604 testEchoOkHeaderWithEmptyBody(null); 605 } 606 607 612 public void testT4() throws Exception { 613 testEchoOkHeaderWithEmptyBody(""); 614 } 615 616 621 public void testT5() throws Exception { 622 Call call = new Call(DOC_ENDPOINT); 623 call.setOperationStyle(Style.DOCUMENT); 624 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 625 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS); 626 SOAPHeaderElement header = new SOAPHeaderElement(TEST_NS, "echoOk"); 627 header.setRole(ROLE_B); 628 header.setObjectValue("test header"); 629 reqEnv.addHeader(header); 630 SOAPEnvelope respEnv = call.invoke(reqEnv); 631 assertTrue("Got unexpected header!", respEnv.getHeaders().isEmpty()); 632 } 633 634 639 public void testT6() throws Exception { 640 Call call = new Call(INTERMEDIARY_ENDPOINT); 641 call.setOperationStyle(Style.DOCUMENT); 642 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 643 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS); 644 SOAPHeaderElement header = new SOAPHeaderElement(TEST_NS, "echoOk"); 645 header.setRole(ROLE_C); 646 header.setObjectValue("test header"); 647 reqEnv.addHeader(header); 648 SOAPEnvelope respEnv = call.invoke(reqEnv); 649 SOAPHeaderElement respHeader = 650 respEnv.getHeaderByName(TEST_NS, "responseOk"); 651 assertNotNull(respHeader); 652 assertEquals("test header", respHeader.getValue()); 653 } 654 655 660 public void testT12() throws Exception { 661 Call call = new Call(DOC_ENDPOINT); 662 call.setOperationStyle(Style.DOCUMENT); 663 call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS); 664 SOAPEnvelope reqEnv = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS); 665 SOAPHeaderElement header = new SOAPHeaderElement(TEST_NS, "Unknown"); 666 header.setObjectValue("test header"); 667 header.setMustUnderstand(true); 668 reqEnv.addHeader(header); 669 try { 670 call.invoke(reqEnv); 671 } catch (AxisFault fault) { 672 assertEquals(Constants.FAULT_SOAP12_MUSTUNDERSTAND, 673 fault.getFaultCode()); 674 ArrayList headers = fault.getHeaders(); 675 for (Iterator i = headers.iterator(); i.hasNext();) { 677 SOAPHeaderElement h = (SOAPHeaderElement) i.next(); 678 if (h.getQName().equals(Constants.QNAME_NOTUNDERSTOOD)) { 679 } 681 } 682 return; 683 } 684 fail("Didn't receive expected fault!"); 685 } 686 687 public void test20Soap12TestDocPortEchoOk() throws Exception { 688 test.wsdl.soap12.assertion.Soap12TestDocBindingStub binding; 689 try { 690 binding = (test.wsdl.soap12.assertion.Soap12TestDocBindingStub) 691 new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getSoap12TestDocPort(); 692 } 693 catch (javax.xml.rpc.ServiceException jre) { 694 if(jre.getLinkedCause()!=null) 695 jre.getLinkedCause().printStackTrace(); 696 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 697 } 698 assertNotNull("binding is null", binding); 699 700 binding.setTimeout(60000); 702 703 } 710 711 } 712 | Popular Tags |