This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

InvocationTargetException  RSS feed

Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a demo example to return a object(Company class) via web services.

public class CompanyWS{

* @return company object
public Company getCompanyData(int optionalInt){
Company company = new Company();
String [] employeeNames = new String[] { "Hari", "Vijay" , "Nischal" };
company.companyID = 8929;
company.companyName = "ABC";
company.employeeNames = employeeNames;
return company;

class Company {
public int companyID;
public String companyName;
public String[ ] employeeNames;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class CompanyClient {

public static void main(String [] args) throws Exception {

Service service = new Service();
Call call = (Call)service.createCall();
String endpoint = "http://localhost:8080/axis/CompanyWS.jws";
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName(new QName("getCompanyData"));

call.addParameter("param1", new QName("XSD_INTEGER"),ParameterMode.IN);
call.setReturnType(new QName("XSD_ANYTYPE"));
Integer[] inputParams = new Integer[]{new Integer(2)};

Object responseObject = new Object();
responseObject = (Object)call.invoke(inputParams);

System.out.println("Got responseObject: " + responseObject);


The problem is when line:
responseObject = (Object)call.invoke(inputParams);

is gives following error:

faultCode: {}Server.userException
faultString: java.lang.reflect.InvocationTargetException

at org.apache.axis.message.SOAPFaultBuilder.createFault(
at org.apache.axis.message.SOAPFaultBuilder.endElement(
at org.apache.axis.encoding.DeserializationContext.endElement(
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(
at org.apache.axis.encoding.DeserializationContext.parse(
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(
at org.apache.axis.Message.getSOAPEnvelope(
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(
at org.apache.axis.client.AxisClient.invoke(
at org.apache.axis.client.Call.invokeEngine(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at CompanyClient.main(
Exception in thread "main"

I have checked few help via google....but still unable to resolve it.
Please help me to solve that.

Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add more:
Company.class is in axis\WEB-INF\classes.(Is it right?)

and CompanyWS.jws is in axis folder.
(It generates CompanyWS.class + Company.class in axis\WEB-INF\jwsClasses.
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!