Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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.
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!