aspose file tools*
The moose likes Web Services and the fly likes Junit Test Case for axis WebService Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Junit Test Case for axis WebService" Watch "Junit Test Case for axis WebService" New topic
Author

Junit Test Case for axis WebService

Gobind Singh
Ranch Hand

Joined: Aug 04, 2006
Posts: 62
I have written a test case using junit. I am executing it through the Eclipse 3.2 IDE.

The test case is a client for a webservice. it is as follows:

public class TestCategoryReports extends TestCase {
private String localHostEndPoint;
private String targetNameSpace;
private String serviceName;
private String portName;

public TestCategoryReports() {
localHostEndPoint= "http://127.0.0.1:8181/axis/services/MstrCatReports?wsdl";
targetNameSpace = "urn:com.aah.CategoryReports";
serviceName = "CategoryReports";
portName = "MstrCategoryReports";
}


public void testGetEnterpriseProdGroupReportOneItem() {
BranchAccount[] barray = new BranchAccount[1];
BranchAccount bAccount = new BranchAccount("606R", "00104034J");
barray[0] = bAccount;
Service service = new Service();
try{
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(localHostEndPoint));
call.setOperation(new QName(targetNameSpace),"getEnterpriseProdGroupReport");
EnterpriseProductCategoryReportOutput ret = (EnterpriseProductCategoryReportOutput)call.invoke(barray);
}catch(Exception e){
System.out.println("Exception Caught");
fail("exception caught " + e);
}
}

Whenever I execute this test case it fails with:

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2448)
at org.apache.axis.client.Call.invoke(Call.java:2347)
at org.apache.axis.client.Call.invoke(Call.java:1804)
at com.aah.categoryReports.axis.TestCategoryReports.testGetEnterpriseProdGroupReportNoItems(TestCategoryReports.java:43)
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:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


I know my webservice code works since I can call it from a web based diagnostic tool that I have (SoapScope). I have also run org.apache.axis.utils.tcpmon and it shows that the request and response is coming back correct when I run the junit test case.

The problem is that in eclipse, I get the above exception trace.

Any ideas???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junit Test Case for axis WebService