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

3316A Working Example of a PERL SERVER to .NET

Expand Messages
  • nayanah
    Jan 19, 2004
    • 0 Attachment
      i finally did it.... without having to use the Serializer here is a
      working example of SOAP::Lite perl server to .NET

      all i had to do with play with the namespaces and yeahhhhh i got it
      to work omg i am like so happy right now ahahah anyways here is for
      this who would like to see it

      i feel its good to contribue to this group because for 4 days i
      learnt alot about SOAP::Lite from here

      ========================== CODE ========================

      #!/usr/bin/perl

      use SOAP::Transport::HTTP;

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('TradeTechDemo')
      -> handle;


      package TradeTechDemo;

      sub doGetHblDetail {
      my ($class, $hbl) = @_;

      $ENV{'HBL'} = $hbl;

      $tmfile = "/tmp/crft.$$.csv";

      $ENV{'TMFILE'} = $tmfile;
      $ENV{'TERM'} = "linux";

      #my @args = "/appl/fp/dreport Ftrans -f CLFR_download -a -m
      DEMO -u"; # -u > /dev/null 2> /dev/null";

      #call fpwebonsave in Ftariff to take care of the rate aut
      system("/appl/fp/dreport Ftrans -f CLFR_download -a -m DEMO -u -
      u > /dev/null 2> /dev/null"); #l == 0
      #or die "system @args failed: $?";

      #$soap = SOAP::Lite #the result varible will hold the
      return value of the function
      #-> xmlschema('http://www.w3.org/2001/XMLSchema')
      #-> uri('http://www.tradetech.net/cgi-bin/SOAPtest.cgi') #Map
      perl to .NET Namespace
      #-> on_action(sub{sprintf '%s/%s', $class }) #Fix SOAP::Lite
      SOAPAction headers to work with .NET
      #-> proxy('http://www.tradetech.net/cgi-bin/SOAPtest.cgi');#get
      the proxy stub
      #-> serializer(MySerializer->new)

      my $testfile = $tmfile; #"/home/nayana/SOAP/CLRF.csv";
      open (CSV, $testfile) or die "Error Opening File Search
      didnt produce results";
      my @CSV = <CSV>;
      close (CSV);
      $counter = 0;

      foreach $csvline (@CSV) {
      if ($csvline =~ m/^\"H\"\,(.*)$/)
      {
      my $headerline = $1;

      my @HEADER = split(",", $headerline);
      $HEADER[0] =~ s/\"//g;
      $dept = $HEADER[0];
      $HEADER[1] =~ s/\"//g;
      $fileNo = $HEADER[1]; # =~ s/\"//g;
      $HEADER[2] =~ s/\"//g;
      $custNo = $HEADER[2]; #=~ s/\"//g;
      $HEADER[3] =~ s/\"//g;
      $billTo = $HEADER[3]; #=~ s/\"//g;
      $HEADER[4] =~ s/\"//g;
      $invoiceDate = $HEADER[4];
      $HEADER[5] =~ s/\"//g;
      $divisionNo = $HEADER[5];
      $HEADER[6] =~ s/\"//g;
      $masterBill = $HEADER[6]; # =~ s/\"//g;
      $HEADER[7] =~ s/\"//g;
      $description = $HEADER[7]; # =~ s/\"//g;
      $HEADER[8] =~ s/\"//g;
      $quantity = $HEADER[8]; # =~ s/\"//g;
      $HEADER[9] =~ s/\"//g;
      $weight = $HEADER[9]; # =~ s/\"//g;
      $HEADER[10] =~ s/\"//g;
      $carrier = $HEADER[10]; # =~ s/\"//g;
      $HEADER[11] =~ s/\"//g;
      $departureDate = $HEADER[11]; # =~ s/\"//g;
      $HEADER[12] =~ s/\"//g;
      $origin = $HEADER[12]; # =~ s/\"//g;
      $HEADER[13] =~ s/\"//g;
      $destination = $HEADER[13]; # =~ s/\"//g;

      }
      elsif ($csvline =~ m/^\"D\"\,(.*)$/)
      {
      my $detailline = $1;
      my @DETAIL = split(",",$detailline);

      #$soapenv = SOAP::Lite->encodingspace('ns1');

      $DETAIL[14] =~ s/\"//g;
      $DETAIL[15] =~ s/\"//g;
      $DETAIL[16] =~ s/\"//g;
      $DETAIL[17] =~ s/\"//g;
      $DETAIL[18] =~ s/\"//g;
      $DETAIL[19] =~ s/\"//g;
      $DETAIL[20] =~ s/\"//g;

      $myArray[$counter] = \SOAP::Data->name
      ('arapDetail')->value(
      SOAP::Data->name('chargeCode' =>
      $DETAIL[14])->type('string'),
      SOAP::Data->name('arAmount' =>
      $DETAIL[15])->type('string'),
      SOAP::Data->name('apAmount' =>
      $DETAIL[16])->type('string'),
      SOAP::Data->name('venderCode' =>
      $DETAIL[17])->type('string'),
      SOAP::Data->name('reference' =>
      $DETAIL[18])->type('string'),
      SOAP::Data->name('transactionDate'
      => $DETAIL[19])->type('string'),
      SOAP::Data->name('referenceNo' =>
      $DETAIL[20] )->type('string'))->type('arapDetail');
      $counter = $counter + 1;

      }

      }

      return SOAP::Data
      ->name("doGetHblDetailResponse" => \SOAP::Data->value
      (
      SOAP::Data->name("dept" => $dept)->type
      ('string'),
      SOAP::Data->name("fileNo" => $fileNo)->type
      ('string'),
      SOAP::Data->name("custNo" => $custNo)->type
      ('string'),
      SOAP::Data->name("billTo" => $billTo)->type
      ('string'),
      SOAP::Data->name("invoiceDate" =>
      $invoiceDate)->type('string'),
      SOAP::Data->name("divisionNo" =>
      $divisionNo)->type('string'),
      SOAP::Data->name("masterBill" =>
      $masterBill)->type('string'),
      SOAP::Data->name("description" =>
      $description)->type('string'),
      SOAP::Data->name("quantity" => $quantity)-
      >type('string'),
      SOAP::Data->name("weight" => $weight)->type
      ('string'),
      SOAP::Data->name("carrier" => $carrier)->type
      ('string'),
      SOAP::Data->name("departureDate" =>
      $departureDate)->type('string'),
      SOAP::Data->name("arrivalDate" =>
      $arrivalDate)->type('string'),
      SOAP::Data->name("origin" => $origin)->type
      ('string'),
      SOAP::Data->name("destination" =>
      $destination)->type('string'),
      SOAP::Data->name("arapDetails" =>
      \SOAP::Data->value(SOAP::Data->name("item"
      => @myArray)
      ->attr({"xsi:type"
      => "namesp1:arapDetail"}))
      )->attr({'namesp2:arrayType'
      => "namesp1:arapDetail[$counter]", "xsi:type"
      => "namesp2:Array", "xmlns:namesp2"
      => "http://schemas.xmlsoap.org/soap/encoding/"})
      ));

      }