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

TestOutParams

public class TestOutParams extends junit.framework.TestCase
Test org.apache.axis.handlers.RPCDispatcher
author
Sam Ruby

Fields Summary
private final String
serviceURN
private final String
message
A fixed message, since the return is hardcoded
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
Constructors Summary
public TestOutParams(String name)


       
        super(name);
        server.init();
    
Methods Summary
public static voidmain(java.lang.String[] args)

      try {
        TestOutParams tester = new TestOutParams("RPC test");
        tester.testOutputParams();
      } catch (Exception e) {
        e.printStackTrace();
      }
    
public voidtestOutputParams()
Test returning output params

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

        // ??? Do we need to register the handler?

        SOAPService service = new SOAPService(h);
        provider.deployService(serviceURN, service);

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

        // Create the message context
        MessageContext msgContext = new MessageContext(server);

        // Construct the soap request
        SOAPEnvelope envelope = new SOAPEnvelope();
        msgContext.setRequestMessage(new Message(envelope));

        client.addParameter(
                new QName("", "string"),
                XMLType.XSD_STRING,
                javax.xml.rpc.ParameterMode.IN);
        client.addParameter(
                new QName("", "out1"),
                XMLType.XSD_STRING,
                javax.xml.rpc.ParameterMode.OUT);
        client.addParameter(
                new QName("", "out2"),
                XMLType.XSD_FLOAT,
                javax.xml.rpc.ParameterMode.OUT);
        client.setReturnType(XMLType.XSD_INT);
        // Invoke the Axis server
        Object ret = client.invoke(serviceURN, "method",
                                new Object [] { "test" });

        Map outParams = client.getOutputParams();
        assertNotNull("No output Params returned!", outParams);

        Object param = outParams.get(new QName(null, "out1"));
        assertEquals("Param out1 does not equal expected value", ServiceHandler.OUTPARAM1, param);

        param = outParams.get(new QName(null, "out2"));
        assertEquals("Param out2 does not equal expected value", ServiceHandler.OUTPARAM2, param);

        assertEquals("Return value does not equal expected value", ((Integer)ret).intValue(), ServiceHandler.RESPONSE.intValue());