I'm really sorry about this email but I've hit a brick wall and can't
get past. First off I'm using Axis 1.2RC with tomcat 4.1.31.

I have a test system that communicates with a service and thats all it
does. But theres a handler thats invoked when the service is invoked.
This handler then makes a service call to a service that puts some
information into a database.

But I keep getting a connection reset?? Some people have said thats
because of a timeout. But I don't think thats what it is.
Here's my code if you can understand it.

*******************************************
Loghandler.java //The Handler!
*******************************************
package Myne;

import org.apache.axis.AxisFault;
import org.apache.axis.Handler;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

public class LogHandler1 extends BasicHandler {
      public void invoke(MessageContext msgContext) throws AxisFault{
        /** Log an access each time we get invoked.
        */
        try {
          Handler serviceHandler = msgContext.getService();
          String hostname = (String)getOption("hostname");
          if((hostname == null) || (hostname.equals("")))
              System.out.println("No hostname Specified");
              String endpoint = "http://localhost:8080/axis/counting.jws";;
              String method = "count";
              Service  service = new Service();
              Call     call    = (Call) service.createCall();
              call.setTargetEndpointAddress( new java.net.URL(endpoint) );
              call.setOperationName( method );
              call.addParameter( "op1", XMLType.SOAP_STRING,
ParameterMode.IN );
              call.setReturnType( XMLType.SOAP_STRING );
              call.invoke( new Object [] {hostname});// This does all the work!

        } catch (Exception e) {
          throw AxisFault.makeFault(e);
        }
      }
}
*******************************************
Service//A quick service
*******************************************
package Myne;

public class Service
{
  public String testMethod(){
      return "Hi, you've reached the testMethod.";
  }
}
*******************************************
Client//A quick service
*******************************************
package Myne;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;
import javax.xml.namespace.QName;

public class Client{
  public static void main(String [] args){
      try {
          Options options = new Options(args);
          String endpointURL = options.getURL();
          Service  service = new Service();
          Call     call    = (Call) service.createCall();
          call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
          call.setOperationName( new QName("TestService", "testMethod") );
          String res = (String) call.invoke( new Object[] {} );
          System.out.println( res );
      } catch (Exception e) {
          System.err.println(e.toString());
      }
  }
}

*******************************************
counting.jws//The service that does the database stuff
*******************************************
import java.sql.*;
import java.util.Date;

public class counting{
      public void count(String host)throws Exception{
              try{
                      int accesses = 0;
                      String accessS="";
                      Date date = new Date();
                      testDriver();
                      Connection con = getConnection();
                      Statement s = con.createStatement();
                      ResultSet rs = s.executeQuery("SELECT * FROM
access WHERE hostname
= "+host+"");
                      if(rs.next()==false){
                              accessS ="0";
                      }
                      else
                              accessS = (rs.getObject("counting")).toString();
                      accesses = Integer.parseInt(accessS);
                      int numAccesses = accesses+1;
                      s.execute("INSERT INTO access(hostname,Counting,lastDate)
values('"+host+"',"+numAccesses+","+date+")");
                      s.close();
              }
              catch(Exception e){
                      System.out.println("Something is wrong");
              }
      }

      protected static void testDriver() throws Exception {
      //Some database stuff
      }
      protected static Connection getConnection() throws Exception {
      //Some database stuff
      }

}

**************************************
deploy.wsdd // I might have made a mistake here?
**************************************
<deployment xmlns="http://xml.apache.org/axis/wsdd/";
          xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>

<!-- define the logging handler configuration -->
<handler name="track" type="java:Myne.LogHandler1">
<parameter name="database" value="Access"/>
<parameter name="hostname" value="http://localhost:8080/example4/service"/>
</handler>

<!-- define the service, using the log handler we just defined -->
<service name="TestService" provider="java:RPC">
<requestFlow>
 <handler type="track"/>
</requestFlow>

<parameter name="className" value="Myne.Service"/>
<parameter name="allowedMethods" value="*"/>
</service>

</deployment>
*********************************************
if there's anything else anyone needs to see please let me know? I
really have hit a brick wall. I cant go anywhere without getting this
right?

Any Help would be much appreciated!!!

Dan O'Neill

Reply via email to