DII client question
acxjbertr May 30, 2006 1:02 PMI am attempting to write a stand-alone JUnit test to invoke and validate a web service I have running in JBoss 4.0.4GA (JDK 5). According to http://labs.jboss.com/portal/jbossws/user-guide/en/html/clients.html all I need to do is use this:
public void testEchoString() throws Exception
{
ServiceFactoryImpl factory = new ServiceFactoryImpl();
Service service = factory.createService(new QName("ANY_SERVICE_NAME"));
Call call = service.createCall();
call.setOperationName(new QName(TARGET_NAMESPACE, "echoString"));
call.addParameter("String_1", Constants.TYPE_LITERAL_STRING, ParameterMode.IN);
call.addParameter("String_2", Constants.TYPE_LITERAL_STRING, ParameterMode.IN);
call.setReturnType(Constants.TYPE_LITERAL_STRING);
call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);
String hello = "Hello";
String world = "world!";
Object retObj = call.invoke(new Object[]{hello, world});
assertEquals(hello + world, retObj);
}However, the "echoString" service takes simple String objects as input and my service takes a custom object. I have tried modifying the code to use my object but I am getting an exception. Here is my code:
public void testEchoString() throws Exception {
ServiceFactoryImpl factory = new ServiceFactoryImpl();
Service service = factory.createService(new QName("JBossTest2"));
Call call = service.createCall();
call.setOperationName(new QName("http://us.mycompany.com/jbosstest2/1.0", "prescreen"));
call.addParameter("JBossTest2Request", new QName("JBossTest2Request"), ParameterMode.IN);
call.setReturnType(new QName("com.mycompany.us.test.JBossTest2Reply"));
call.setTargetEndpointAddress("http://jbertr1005:8080/jbosstest2/1.0");
String hello = "Hello";
String world = "world!";
Object retObj = call.invoke(new Object[] { new JBossTest2Request() });
assertEquals(hello + world, retObj);
}
And here is the exception I am receiving:
java.lang.IllegalArgumentException: Invalid null parameter at org.jboss.ws.jaxrpc.CallImpl.setReturnType(CallImpl.java:349) at org.jboss.ws.jaxrpc.CallImpl.setReturnType(CallImpl.java:341) at com.mycompany.us.test.ws.WSTestCase.testEchoString(WSTestCase.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
How do I get a simple DII client to invoke a web service that uses custom objects for input and output?