Loading ...
Sorry, an error occurred while loading the content.

Soaplite server - Tomcat servlet client - Simple plumbing question please.

Expand Messages
  • jmdevel
    I am wondering/hoping/begging if someone could help a newbie with a simple Tomcat soap client talking to a SoapLite server. I am sure I am missing a very
    Message 1 of 1 , Sep 16, 2005
    • 0 Attachment
      I am wondering/hoping/begging if someone could help a newbie with a
      simple Tomcat soap client talking to a SoapLite server.

      I am sure I am missing a very significant piece of the jigsaw puzzle
      here (at least) in the servlet, and could possibly also be missing
      critical pieces/modules in the Tomcat setup ?

      Here is what I have so far:


      Platform information:

      OS HP-UX B.11.11
      perl version 5.8.2
      soaplite 0.65_6
      Tomcat version 5.5.9 with downloaded jar files ...
      - soap version-2.2
      - javamail-1_3_2
      - jaf-1_0_2-upd2
      - Xerces-J-bin.1.2.3


      1) Simple Soaplite server (daemon)
      -----------------------------------

      #!/usr/bin/perl -w

      use SOAP::Transport::HTTP;

      use strict;
      use warnings;


      # don't want to die on 'Broken pipe' or Ctrl-C
      $SIG{PIPE} = $SIG{INT} = 'IGNORE';

      my $daemon = SOAP::Transport::HTTP::Daemon
      -> new (LocalPort => 7001)
      -> dispatch_to('test');

      print "Contact to SOAP server at ", $daemon->url, "\n";
      $daemon->handle;


      package test;
      sub hi{
      return "\nfoobar...\n";
      }

      sub getsql {

      my $sql = "select * from fred";
      return $sql ;

      }



      2) Simple soaplite client
      ---------------------------

      #!/usr/bin/perl -w

      use SOAP::Lite;

      my $s = SOAP::Lite
      -> uri('http://myhost/test') # sub myhost for real host...
      -> proxy('http://myhost:7001/test')
      -> getsql();


      die $s->faultstring if $s->fault;


      print "\n";
      print $s->result ;
      print "\n";


      Program outputs ==> select * from fred

      Ok so far..now the hard part...simple servlet to talk to soaplite
      daemon..



      3) summary of the core of the servlet code..


      // ..sniped from here.....

      String sql;

      URL url = new URL ("http://myhost:7001/test");

      // Build the call.
      Call call = new Call();

      call.setTargetObjectURI("http://myhost/test");
      call.setMethodName("getsql");
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

      Response resp = null;
      try {
      resp = call.invoke(url, "" );
      }
      catch (SOAPException e) {
      System.err.println("Caught SOAPException (" +
      e.getFaultCode() + "): " +
      e.getMessage());
      }

      // Check the response.
      if ( resp.generatedFault() ) {

      Fault fault = resp.getFault ();
      System.out.println("The call failed: ");
      System.out.println("Fault Code = " + fault.getFaultCode());
      System.out.println("Fault String = " + fault.getFaultString());
      }
      else {

      Parameter result = resp.getReturnValue();
      sql= (String) result.getValue();
      }

      // ...again snipped here...

      I know the servlet is completly wrong..so, some direction here is
      really appreciated.

      Also, do I need any further modules for the tomcat? I have only
      downloaded and installed those mentioned above.
      What have I missed?...


      Any help greatly appreciated!
      Thanks
    Your message has been successfully submitted and would be delivered to recipients shortly.