I am trying to run a simple xindice webservice, which i have put in the 
following directory: $TOMCAT_HOME/webapps/axis/Example1.jws

I wrote a simple client called "ExClient.java" which makes connection to this 
webservie. But on running that client i get the following error

Exception in thread "main" Internal Server Error
        at 
org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:518)
        at 
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71
)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:154)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:121)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:174)
        at org.apache.axis.client.Call.invoke(Call.java:1905)
        at org.apache.axis.client.Call.invoke(Call.java:1690)
        at org.apache.axis.client.Call.invoke(Call.java:1608)
        at org.apache.axis.client.Call.invoke(Call.java:1169)
        at ExClient.main(ExClient.java:43)


ExClient looks like this :

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.rpc.ParameterMode;
public class ExClient
{
   public static void main(String [] args) throws Exception {
       System.out.print("READY TO ROLL .....\n");
       Options options = new Options(args);
       String endpoint = "http://localhost:"; + options.getPort() +
                         "/axis/Example1.jws";
       args = options.getRemainingArgs();
       String method = args[0];
       if (!(method.equals("runQuery"))) {
           System.err.println("Usage: ExClient runQuery ");
           return;
       }
       Service  service = new Service();
       Call     call    = (Call) service.createCall();

       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
       call.setOperationName( method );
       call.addParameter( "op1", XMLType.XSD_STRING, ParameterMode.IN );
       call.setReturnType( XMLType.XSD_STRING );

System.out.println("args[0]: <" + args[0] + ">");
System.out.println("args[1]: <" + args[1] + ">");
       String  ret = (String) call.invoke( new Object [] {args[1]});
       System.out.println("Got result : " + ret);
   }
}



Xindice web service looks like this:

import org.apache.xindice.*;
import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

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

        Example1 e = new Example1();
        String a = e.runQuery("asfd");
        System.out.println(a);

        }
 public String runQuery(String a) throws Exception {
      Collection col = null;
      String totRes = null;
      try {
         String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
         Class c = Class.forName(driver);

         Database database = (Database) c.newInstance();
         DatabaseManager.registerDatabase(database);
         col =
            DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");

         String xpath = "//person[fname='John']";
         XPathQueryService service =
            (XPathQueryService) col.getService("XPathQueryService", "1.0");
         ResourceSet resultSet = service.query(xpath);
         ResourceIterator results = resultSet.getIterator();
         totRes = "Input: " + a + "\n";
         while (results.hasMoreResources()) {
            Resource res = results.nextResource();
            totRes = totRes+ (String) res.getContent();
         }
      }
      catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " + e.errorCode + " " +
            e.getMessage());
      }
      finally {
         if (col != null) {
            col.close();
         }
         return(totRes);
      }
   }
}
Can anyone help me with this problem?



Abhishek

Reply via email to