File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) 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

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= "";
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();
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(
at org.apache.axis.encoding.DeserializationContext.startElement(
at org.apache.axis.message.SAX2EventRecorder.replay(
at org.apache.axis.message.MessageElement.publishToHandler(
at org.apache.axis.message.RPCElement.deserialize(
at org.apache.axis.message.RPCElement.getParams(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at com.aah.categoryReports.axis.TestCategoryReports.testGetEnterpriseProdGroupReportNoItems(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at junit.framework.TestCase.runTest(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

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:
subject: Junit Test Case for axis WebService
jQuery in Action, 3rd edition