This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Services and the fly likes InvocationTargetException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Web Services
Bookmark "InvocationTargetException" Watch "InvocationTargetException" New topic


Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
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

Joined: Mar 01, 2002
Posts: 72
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.
Don't get me started about those stupid light bulbs.
subject: InvocationTargetException
It's not a secret anymore!