FileDocCategorySizeDatePackage
TestOutParams.javaAPI DocApache Axis 1.43800Sat Apr 22 18:57:28 BST 2006test.outparams2

TestOutParams

public class TestOutParams extends TestCase

Fields Summary
private final String
message
A fixed message, with no parameters
private org.apache.axis.client.Service
s_service
private org.apache.axis.client.Call
client
private org.apache.axis.configuration.SimpleProvider
provider
private org.apache.axis.server.AxisServer
server
private static boolean
called
Constructors Summary
public TestOutParams(String name)


       
        super(name);
        server.init();
    
public TestOutParams()

	super("Test Out Params");
    
Methods Summary
public static voidmain(java.lang.String[] args)

	try {
	    TestOutParams tester = new TestOutParams("OutParams Test");
	    tester.testOutputParams();
	} catch (Exception e) {
	    e.printStackTrace();
	}
    
public voidserviceMethod(java.lang.String in1, javax.xml.rpc.holders.StringHolder out1)

	called = true;
    
public voidtestOutputParams()

        // Register the service
        s_service = new Service();
        client  = (Call) s_service.createCall();

	SOAPService service = new SOAPService(null, 
                                              new RPCProvider(),
                                              null);
	service.setName("TestOutParamsService");
        service.setOption("className", "test.outparams2.TestOutParams");
        service.setOption("allowedMethods", "serviceMethod");

        EngineConfiguration defaultConfig =
            (new DefaultEngineConfigurationFactory()).getServerEngineConfig();
        SimpleProvider config = new SimpleProvider(defaultConfig);
        config.deployService("outParamsTest", service);
        provider.deployService("outParamsTest", service);

        // Make sure the local transport uses the server we just configured
        client.setTransport(new LocalTransport(server));

	Message msg = new Message(message, false);
	SOAPEnvelope env = msg.getSOAPEnvelope();

	// test invocation. test Holder parameter defaults to INOUT type
	client.invoke(env);
	
	// method was succesfully invoked
	assertTrue(called);
	
	ServiceDesc description = null;
	OperationDesc operation = null;
	ParameterDesc parameter = null;

	description = service.getServiceDescription();
	operation = description.getOperationByName("serviceMethod");
	parameter = operation.getParamByQName(new QName("", "out1"));
	    
	assertEquals(ParameterDesc.INOUT, parameter.getMode());

	// Changing output parameter to OUT type.
	parameter.setMode(ParameterDesc.OUT);

	// rest called
	called = false;

	// invoke again
	client.invoke(env);
	assertTrue(this.called);