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

working example of Perl Server to .NET Client

Expand Messages
  • nayanah
    hi.. well i ve manage to come along way taking the fact that i am only 4 days old to SOAP.. i manage to get it talk with .NET but then once i put an array in
    Message 1 of 2 , Jan 19, 2004
    • 0 Attachment
      hi.. well i've manage to come along way taking the fact that i am
      only 4 days old to SOAP.. i manage to get it talk with .NET but then
      once i put an array in side .NET starts complaning again here is my
      code, can anyone give any ideas or if you have a working example of
      a similar situation which works with a .NET client could you post it
      some where.

      thanks in advance

      ####################################### 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)
      ->type("arapDetail"))
      )->type("arapDetail[$counter]")->attr
      ({'namesp2:arrayType' => "namesp2:arapDetail[$counter]"})
      ));

      }
    • orb_soft
      I used the literal serializer verbatim from the following as contributed by Alberto: http://ads.harvard.edu/~alberto/SOAP/ Build your message using SOAP::Data.
      Message 2 of 2 , Jan 19, 2004
      • 0 Attachment
        I used the literal serializer verbatim from the following as
        contributed by Alberto:
        http://ads.harvard.edu/~alberto/SOAP/

        Build your message using SOAP::Data. The serializer will 'literalize'
        the message. Combine this with a matching WSDL file (which you have
        to build manually) and a .NET client can read it.

        To access the service from a .NET web page (you probably already know
        this):
        0. Download the .NET SDK (for free?) from microsoft.com
        1. build the stubs c# file using for example 'wsdl.exe
        http://www.yourserver/servicedesc.wsdl'
        2. compile using 'csc /t:library servicedesc.cs'
        3. copy the resulting servicedesc.dll to the web server's bin
        directory
        4. Access the web service from an '.aspx' page which you would
        write in VB or C#, etc..

        So far the most complex object I have passed through this serializer
        to a .NET client is an array of array. But I have no reason to
        suspect that any kind of complex object will not work. So long as it
        can be described in the WSDL file and the SOAP::Data call can build
        it!

        BTW: if you have .NET a great tool for testing web services is Web
        Services Studio. Free from:
        http://www.gotdotnet.com
        (not sure if it runs on the .NET runtime or if you need the SDK)
        It generates the client automatically from the wsdl file and shows
        the raw SOAP. There are several tools like this out there, but it is
        one that I tried and was able to use.

        Good luck,

        Maurice

        --- In soaplite@yahoogroups.com, "nayanah" <nayana@t...> wrote:
        > hi.. well i've manage to come along way taking the fact that i am
        > only 4 days old to SOAP.. i manage to get it talk with .NET but
        then
        > once i put an array in side .NET starts complaning again here is my
        > code, can anyone give any ideas or if you have a working example of
        > a similar situation which works with a .NET client could you post
        it
        > some where.
        >
        > thanks in advance
        >
        > ####################################### 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)
        > ->type("arapDetail"))
        > )->type("arapDetail
        [$counter]")->attr
        > ({'namesp2:arrayType' => "namesp2:arapDetail[$counter]"})
        > ));
        >
        > }
      Your message has been successfully submitted and would be delivered to recipients shortly.