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

Re: Newbie question: simple complex type

Expand Messages
  • andre_debruin
    Thank you so much for the reply, that was most excellent, man I wish I could E-mail you a beer ! (hm, well there is an idea). I have copied the working code
    Message 1 of 3 , Mar 31, 2006
    • 0 Attachment
      Thank you so much for the reply, that was most excellent,
      man I wish I could E-mail you a beer !
      (hm, well there is an idea).


      I have copied the working code below for posterity.

      One question I should have asked before:

      I am to implement both the server and client side of
      a web service, the server will be Java, the clients will
      be both perl and Java.

      Now.. the application requires me to pass in and return
      a "deep structure" which can be represented as an array
      of structs (few hundred items in the array, some 5 fields
      in the struct).

      Would it make more sense to keep the method call simple and
      pass in the structure as a "blob", i.e. an attachment to
      be parsed by the server side or is that just "not done"
      in web sevices land ?
      (The question is thus related to best practices)






      ========
      Sample code for interfacing with "example5" of the Apache axis 1.3
      distribution, thanks much to Eric Bridger

      #!/usr/bin/env perl

      use SOAP::Lite +trace => qw(debug);

      $serv =
      SOAP::Lite->proxy("http://myhost:8080/axis/services/OrderProcessor");

      $method = SOAP::Data->name("processOrder");

      # from the wsdl:
      # <complexType name="Order">
      # <sequence>
      # <element name="customerName" nillable="true"
      # type="xsd:string"/>
      # <element name="itemCodes" nillable="true"
      # type="impl:ArrayOf_xsd_string"/>
      # <element name="quantities" nillable="true"
      # type="impl:ArrayOf_xsd_int"/>
      # <element name="shippingAddress" nillable="true"
      # type="xsd:string"/>
      # </sequence>
      # </complexType>

      my $order = SOAP::Data->name("arg1" =>
      \SOAP::Data->value( # note the reference here to get nested XML
      SOAP::Data->name("customerName" => 'foo' ),
      SOAP::Data->name("itemCodes" => ['a','b'] ),
      SOAP::Data->name("quantities" => [1,2] ),
      SOAP::Data->name("shippingAddress" => 'addr' ),
      ) );

      $result = $serv->call($method,
      SOAP::Data
      ->name("arg1" => $order ) );

      print $result;
    Your message has been successfully submitted and would be delivered to recipients shortly.