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

Re: [soaplite] Re: Complex objects in SOAP::Lite?

Expand Messages
  • Brian Gilman
    On 6/18/03 10:48 AM, jpeyser wrote: Yes!!!!!! You re a life saver!! So, Here s the final piece of code that works with Axis. I can t
    Message 1 of 3 , Jun 18, 2003
    • 0 Attachment
      On 6/18/03 10:48 AM, "jpeyser" <jpeyser@...> wrote:

      Yes!!!!!!

      You're a life saver!! So, Here's the final piece of code that works with
      Axis. I can't thank everyone on this list enough for helping me out. You've
      saved me a lot of headaches! Hopefully this will help out others who are
      trying to make complex objects using SOAP::Lite.



      Best,

      -B

      ----code-----

      #!/usr/bin/perl -w

      use SOAP::Lite;

      #Hacked to support Attachments below
      use SOAP::MIME;
      #need this to build MIME::Entities
      use MIME::Entity;


      #Need this line to make sure that the attachments are properly separated out
      and recognized by Axis
      BEGIN {$MIME::Entity::BOUNDARY_DELIMITER = "\r\n";}

      #start the code
      #get some files for testing
      my ($file1, $file2) = @ARGV;

      my $ent1 = build MIME::Entity
      Type => "text/plain",
      Encoding => "base64",
      Path => $file1,
      Id => 'cid:8AD4BDB760E6118542CD87DD2CFB865C',
      Disposition => "attachment";


      my $ent2 = build MIME::Entity
      Type => "text/plain",
      Encoding => "base64",
      Path => $file2,
      Id => 'cid:58F0C854A225835E07DE1A757DFE2357',
      Disposition => "attachment";

      push @parts, $ent1;
      push @parts, $ent2;


      my $soap = SOAP::Lite
      ->uri("Analysis")
      ->on_action(sub {return "Analysis"})
      ->proxy("http://localhost:9090/axis/servlet/AxisServlet")
      ->parts(@parts)
      ->submitJob(
      SOAP::Data->name("arg0" => 0)->type("xsd:int"),
      SOAP::Data->type('SOAP-ENC:Array')
      ->attr({ 'SOAP-ENC:arrayType' => 'namesp1:ParmInfo[1]'})
      ->name("arg1" =>
      \SOAP::Data->value(createItem('inputfile1', 'true', '',
      '-f1', 'false', 'test1.txt'),
      createItem('inputfile2', 'true', '', '-f2', 'false',
      'test2.txt'))),
      SOAP::Data->name("arg2" =>
      \SOAP::Data->value(createKeyHref('test1.txt',
      'cid:8AD4BDB760E6118542CD87DD2CFB865C'),
      createKeyHref('test2.txt',
      'cid:58F0C854A225835E07DE1A757DFE2357')
      ))
      ->type('ns4:Map')
      ->attr({'xmlns:ns4' => "http://xml.apache.org/xml-soap"}));


      sub createItem {
      my ($d, $i, $l, $n, $o, $v) = @_;
      return SOAP::Data->name('item' =>
      \SOAP::Data->type('namesp2:Map')
      ->attr({'xmlns:namesp2' =>
      "http://xml.apache.org/xml-soap"})
      ->name("attributes" =>
      \SOAP::Data->value(createKeyValue('MODE', 'IN'),
      createKeyValue('TYPE', 'FILE')),
      SOAP::Data->name("description" => $d)->type('xsd:string'),
      SOAP::Data->name("inputFile" => $i)->type('xsd:boolean'),
      SOAP::Data->name("label" => $l)->type('xsd:string'),
      SOAP::Data->name("name" => $n)->type('xsd:string'),
      SOAP::Data->name("outputFile" => $o)->type('xsd:boolean'),
      SOAP::Data->name("value" => $v)->type('xsd:string'),
      )
      );
      }


      sub createKeyValue {
      my ($key, $value) = @_;
      return SOAP::Data->name('item' => \SOAP::Data->value(
      SOAP::Data->name('key' => $key),
      SOAP::Data->name('value' => $value),
      ));
      }

      sub createKeyHref {
      my ($key, $href) = @_;
      return SOAP::Data->name('item' => \SOAP::Data->value(
      SOAP::Data->name('key' => $key),
      SOAP::Data->name('value')->attr({'href' =>
      $href}),
      ));
      }

      ----end code ----



      > Brian,
      > Here is the code to generate your structure. I basically copied
      > the sample code that Byrne Reese attached with his e-mail
      > (ISupplier.pm)
      >
      > Jonathan
      >
      > my $soap = SOAP::Lite
      > ->uri("Analysis")
      > ->on_action(sub {return "Analysis"})
      > ->proxy("http://localhost:9090/axis/servlet/AxisServlet")
      > ->submitJob(
      > SOAP::Data->name("arg0" => 0)->type("xsd:int"),
      > SOAP::Data->type('SOAP-ENC:Array')
      > ->attr({ 'SOAP-ENC:arrayType'
      > => 'namesp1:ParmInfo[1]'})
      > ->name("arg1" =>
      > \SOAP::Data->value(createItem
      > ('inputfile1', 'true', '', '-f1', 'false', 'test1.txt'),
      >
      > createItem('inputfile2', 'true', '', '-
      > f2', 'false', 'test2.txt'))
      > ),
      > SOAP::Data->name("arg2" =>
      > \SOAP::Data->value(createKeyHref
      > ('test1.txt', 'cid:8AD4BDB760E6118542CD87DD2CFB865C'),
      >
      > createKeyHref('test2.txt', 'cid:58F0C854A225835E07DE1A757DFE2357')
      > ))
      > ->type('ns4:Map')
      > ->attr({'xmlns:ns4'
      > => "http://xml.apache.org/xml-soap"})
      > )
      > ;
      >
      >
      > sub createItem {
      > my ($d, $i, $l, $n, $o, $v) = @_;
      >
      > return SOAP::Data->name('item' =>
      > \SOAP::Data->type('namesp2:Map')
      > ->attr({'xmlns:namesp2'
      > => "http://xml.apache.org/xml-soap"})
      > ->name("attributes" =>
      > \SOAP::Data->value
      > (createKeyValue('MODE', 'IN'),
      >
      > createKeyValue('TYPE', 'FILE')
      >
      > ),
      > SOAP::Data->name
      > ("description" => $d)->type('xsd:string'),
      > SOAP::Data->name("inputFile"
      > => $i)->type('xsd:boolean'),
      > SOAP::Data->name("label" =>
      > $l)->type('xsd:string'),
      > SOAP::Data->name("name" =>
      > $n)->type('xsd:string'),
      > SOAP::Data->name("outputFile"
      > => $o)->type('xsd:boolean'),
      > SOAP::Data->name("value" =>
      > $v)->type('xsd:string'),
      > )
      > );
      > }
      >
      >
      > sub createKeyValue {
      > my ($key, $value) = @_;
      > return SOAP::Data->name('item' => \SOAP::Data->value(
      > SOAP::Data->name('key' => $key),
      > SOAP::Data->name('value' => $value),
      > ));
      > }
      >
      > sub createKeyHref {
      > my ($key, $href) = @_;
      > return SOAP::Data->name('item' => \SOAP::Data->value(
      > SOAP::Data->name('key' => $key),
      > SOAP::Data->name('value')->attr({'href' => $href}),
      > ));
      > }
      >
      >
      >
      >
      > --- In soaplite@yahoogroups.com, Brian Gilman <gilmanb@m...> wrote:
      >> Hello Everyone,
      >>
      >> After a considerable amount of time playing with SOAP::Lite, I
      > still
      >> have not been able to serialize my data structure so that apache's
      > Axis
      >> server can understand it. Below is the structure with a bit of code
      > showing
      >> what I've been able to produce so far:
      >>
      >> <?xml version="1.0" encoding="UTF-8"?>
      >> <soapenv:Envelope
      > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      >> <soapenv:Body>
      >> <ns1:submitJob
      >> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      >> xmlns:ns1="Analysis">
      >> <arg0 xsi:type="xsd:int">0</arg0>
      >> <arg1 xsi:type="soapenc:Array" soapenc:arrayType="ns1:ParmInfo
      > [2]"
      >> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      >> <item>
      >> <attributes xsi:type="ns2:Map"
      >> xmlns:ns2="http://xml.apache.org/xml-soap">
      >> <item>
      >> <key xsi:type="xsd:string">MODE</key>
      >> <value xsi:type="xsd:string">IN</value>
      >> </item>
      >> <item>
      >> <key xsi:type="xsd:string">TYPE</key>
      >> <value xsi:type="xsd:string">FILE</value>
      >> </item>
      >> </attributes>
      >> <description xsi:type="xsd:string">input file 1</description>
      >> <inputFile xsi:type="xsd:boolean">true</inputFile>
      >> <label xsi:type="xsd:string"></label>
      >> <name xsi:type="xsd:string">-f1</name>
      >> <outputFile xsi:type="xsd:boolean">false</outputFile>
      >> <value xsi:type="xsd:string">test1.txt</value>
      >> </item>
      >> <item>
      >> <attributes xsi:type="ns3:Map"
      >> xmlns:ns3="http://xml.apache.org/xml-soap">
      >> <item>
      >> <key xsi:type="xsd:string">MODE</key>
      >> <value xsi:type="xsd:string">IN</value>
      >> </item>
      >> <item>
      >> <key xsi:type="xsd:string">TYPE</key>
      >> <value xsi:type="xsd:string">FILE</value>
      >> </item>
      >> </attributes>
      >> <description xsi:type="xsd:string">input file 2</description>
      >> <inputFile xsi:type="xsd:boolean">true</inputFile>
      >> <label xsi:type="xsd:string"></label>
      >> <name xsi:type="xsd:string">-f2</name>
      >> <outputFile xsi:type="xsd:boolean">false</outputFile>
      >> <value xsi:type="xsd:string">test2.txt</value>
      >> </item>
      >> </arg1>
      >> <arg2 xsi:type="ns4:Map" xmlns:ns4="http://xml.apache.org/xml-
      > soap">
      >> <item>
      >> <key xsi:type="xsd:string">test1.txt</key>
      >> <value href="cid:8AD4BDB760E6118542CD87DD2CFB865C"/>
      >> </item>
      >> <item>
      >> <key xsi:type="xsd:string">test2.txt</key>
      >> <value href="cid:58F0C854A225835E07DE1A757DFE2357"/>
      >> </item>
      >> </arg2>
      >> </ns1:submitJob>
      >> </soapenv:Body>
      >> </soapenv:Envelope>
      >>
      >> The code that I wrote looks like this:
      >>
      >>
      >> my $soap = SOAP::Lite
      >> ->uri("Analysis")
      >> ->on_action(sub {return "Analysis"})
      >> ->proxy("http://localhost:9090/axis/servlet/AxisServlet")
      >> # ->parts(@parts)
      >> ->submitJob(
      >> SOAP::Data->name("arg0" => 0)->type("xsd:int"),
      >> SOAP::Data->type('SOAP-ENC:Array')
      >> ->attr({ 'SOAP-ENC:arrayType' => 'namesp1:ParmInfo[1]' })
      >> ->name("arg1" =>
      >> \SOAP::Data->name("item" =>
      >> \SOAP::Data->type('namesp2:Map')
      >> ->attr({'xmlns:namesp2' =>
      >> "http://xml.apache.org/xml-soap"})
      >> ->name("attributes" =>
      >> \SOAP::Data->name("item" =>
      >>
      >> SOAP::Data->name("key" => "MODE"),
      >> SOAP::Data->name("value" => "IN")
      >> ),
      >> \SOAP::Data->name("item" =>
      >>
      >> SOAP::Data->name("key" => "TYPE"),
      >> SOAP::Data->name("value" =>"FILE")
      >> )))));
      >>
      >> This code does not produce the full data structure. Nor was it
      > supposed to!
      >> Is there documentation for how SOAP::Lite serializes perl
      > references vs.
      >> non-references? Also, is there documentation on how SOAP::Lite
      > serializes
      >> multiple levels of elements? What I'm really looking for is for
      > someone
      >> (other than Byrne Reese!) to help me get this data structure coded
      > up! As
      >> I've exhausted all my resources.
      >>
      >> Thanks!
      >>
      >> -B
      >>
      >> --
      >> Brian Gilman <gilmanb@g...>
      >> Group Leader Medical & Population Genetics Dept.
      >> MIT/Whitehead Inst. Center for Genome Research
      >> One Kendall Square, Bldg. 300 / Cambridge, MA 02139-1561 USA
      >> phone +1 617 252 1069 / fax +1 617 252 1902
      >
      >
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
      >

      --
      Brian Gilman <gilmanb@...>
      Group Leader Medical & Population Genetics Dept.
      MIT/Whitehead Inst. Center for Genome Research
      One Kendall Square, Bldg. 300 / Cambridge, MA 02139-1561 USA
      phone +1 617 252 1069 / fax +1 617 252 1902
    Your message has been successfully submitted and would be delivered to recipients shortly.