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

How to use Perl SOAP server and Java Axis Client

Expand Messages
  • bycv3
    Dear All, I am using Perl SOAP server with code ===========Code============= use SOAP::Transport::HTTP; use Data::Serializer; use SOAP::Lite +trace = debug ;
    Message 1 of 1 , Oct 20, 2010
    • 0 Attachment
      Dear All,

      I am using Perl SOAP server with code
      ===========Code=============
      use SOAP::Transport::HTTP;
      use Data::Serializer;
      use SOAP::Lite +trace => 'debug';

      my $daemon = ();
      my %options = (
      port => 9090,
      reuse => 1,
      listen => 1,
      debug => 1,
      readable => 1,
      );
      eval {
      $daemon = SOAP::Transport::HTTP::Daemon->new(
      LocalPort => $options{'port'},
      Reuse => $options{'reuse'},
      Listen => $options{'listen'}
      );
      };
      $daemon->dispatch_to('HelloService')->handle();

      package HelloService;
      use strict;

      sub sayHello {
      my ( $class, $var ) = @_;

      my $report = {
      'name' => 'test',
      'aggregationType' => 'Summary',
      'campaigns' => 5214135,
      'customOptions' => SOAP::Data->name(
      customOptions => qw/AveragePosition Clicks Cpc Keyword AdGroupId/
      ),
      };

      return $report;
      }
      1;
      =========================End======================

      Axis Client Code
      =================

      import java.util.HashMap;
      import java.util.Map;

      import javax.xml.namespace.QName;
      import javax.xml.rpc.ParameterMode;

      import org.apache.axis.client.Call;
      import org.apache.axis.client.Service;
      import org.apache.axis.encoding.ser.MapDeserializerFactory;
      import org.apache.axis.encoding.ser.MapSerializerFactory;

      public class SOAPTest {
      public static void main(String[] args) {
      try {

      String endpoint = "http://localhost:9090";

      Service service = new Service();
      Call call = (Call) service.createCall();

      call.setTargetEndpointAddress(new java.net.URL(endpoint));
      call.setOperationName(new QName(
      "http://www.soaplite.com/PerlAdapter", "test1"));

      Map<String, String> hashMap = new HashMap<String, String>();
      hashMap.put("one", "TOne");

      Object resutl = null;
      try {
      call.addParameter("hashMap",
      org.apache.axis.Constants.SOAP_MAP, ParameterMode.IN);

      MapSerializerFactory bsf = new MapSerializerFactory(Map.class,
      org.apache.axis.Constants.SOAP_MAP);
      MapDeserializerFactory bdf = new MapDeserializerFactory(
      Map.class, org.apache.axis.Constants.SOAP_MAP);

      call.registerTypeMapping(Map.class,
      org.apache.axis.Constants.SOAP_MAP, bsf, bdf);

      call.setReturnType(org.apache.axis.Constants.SOAP_MAP);

      resutl = call.invoke(new Object[] { hashMap });
      } catch (Exception exception) {
      exception.printStackTrace();
      }
      System.out.println(resutl);
      System.out.println(call.getResponseMessage().getSOAPPartAsString());

      } catch (Exception e) {
      System.err.println(e.toString());
      }
      }
      }

      ======================================================

      When I am returning Per hash, I am not able to populate the HashMap. Please suggest a way to do the same. I am able to pass Map from java to perl.

      Thanks
    Your message has been successfully submitted and would be delivered to recipients shortly.