Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Junit Test Case for axis WebService

Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic