1 7 8 package test.wsdl.stubheaders; 9 10 import org.apache.axis.message.SOAPHeaderElement; 11 12 public class StubHeaderServiceTestCase extends junit.framework.TestCase { 13 public StubHeaderServiceTestCase(java.lang.String name) { 14 super(name); 15 } 16 17 public void testStubHeaderServiceWSDL() throws Exception { 18 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 19 java.net.URL url = new java.net.URL (new test.wsdl.stubheaders.StubHeaderServiceLocator().getStubHeaderServiceAddress() + "?WSDL"); 20 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.stubheaders.StubHeaderServiceLocator().getServiceName()); 21 assertTrue(service != null); 22 } 23 24 public void test1StubHeaderServiceEcho() throws Exception { 25 StubHeaderStub binding; 26 try { 27 binding = (test.wsdl.stubheaders.StubHeaderStub) 28 new StubHeaderServiceLocator().getStubHeaderService(); 29 } 30 catch (javax.xml.rpc.ServiceException jre) { 31 if(jre.getLinkedCause()!=null) 32 jre.getLinkedCause().printStackTrace(); 33 throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre); 34 } 35 assertNotNull("binding is null", binding); 36 37 binding.setTimeout(60000); 39 40 binding.setHeader("http://test.org/inputheader", "headerin", "inputvalue"); 42 43 java.lang.String value = null; 45 value = binding.echo(new java.lang.String ()); 46 47 assertEquals("Request header did not reach service", "inputvalue", value); 49 50 SOAPHeaderElement[] hdrs = binding.getResponseHeaders(); 52 assertEquals("List of response headers has the wrong number", 1, hdrs.length ); 53 54 SOAPHeaderElement hdr = binding.getResponseHeader("http://test.org/outputheader", "headerout"); 56 assertNotNull("Cant find header 'headerout' in response", hdr); 57 assertNotNull("Header object value is NULL", hdr.getObjectValue()); 58 assertEquals("Response header did not arrive as expected", "outputvalue", hdr.getObjectValue()); 59 60 } 62 63 } 64 | Popular Tags |