FileDocCategorySizeDatePackage
StubHeaderServiceTestCase.javaAPI DocApache Axis 1.42606Sat Apr 22 18:57:26 BST 2006test.wsdl.stubheaders

StubHeaderServiceTestCase

public class StubHeaderServiceTestCase extends TestCase
StubHeaderServiceTestCase.java Test case. Add a SOAP header using the Stub APIs and make sure the service returns a SOAP header that we can read.

Fields Summary
Constructors Summary
public StubHeaderServiceTestCase(String name)

        super(name);
    
Methods Summary
public voidtest1StubHeaderServiceEcho()

        StubHeaderStub binding;
        try {
            binding = (test.wsdl.stubheaders.StubHeaderStub)
                          new StubHeaderServiceLocator().getStubHeaderService();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            if(jre.getLinkedCause()!=null)
                jre.getLinkedCause().printStackTrace();
            throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
        }
        assertNotNull("binding is null", binding);

        // Time out after a minute
        binding.setTimeout(60000);

        // Set header value via the Stub API
        binding.setHeader("http://test.org/inputheader", "headerin", "inputvalue");

        // Test operation
        java.lang.String value = null;
        value = binding.echo(new java.lang.String());

        // validate input header was echoed back
        assertEquals("Request header did not reach service", "inputvalue", value);

        // Check that getting the list of response headers works
        SOAPHeaderElement[] hdrs = binding.getResponseHeaders();
        assertEquals("List of response headers has the wrong number", 1, hdrs.length );

        // Get response header using ONLY the Stub API
        SOAPHeaderElement hdr = binding.getResponseHeader("http://test.org/outputheader", "headerout");
        assertNotNull("Cant find header 'headerout' in response", hdr);
        assertNotNull("Header object value is NULL", hdr.getObjectValue());
        assertEquals("Response header did not arrive as expected", "outputvalue", hdr.getObjectValue());

        // Everything is OK
    
public voidtestStubHeaderServiceWSDL()

        javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
        java.net.URL url = new java.net.URL(new test.wsdl.stubheaders.StubHeaderServiceLocator().getStubHeaderServiceAddress() + "?WSDL");
        javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.stubheaders.StubHeaderServiceLocator().getServiceName());
        assertTrue(service != null);