I was tired of writing a large complex data with plain SOAP::Data and was so glad to have found SOAP::Data::ComplexType, but I couldn't make a soap array with it. I tried to do exactly as the sample code does but the sample didn't even compile and I had to modify it a bit.
#!C:/perl/bin/perl -w use strict; use SOAP::Data::ComplexType; package My::Complex; use base qw(SOAP::Data::ComplexType); use constant OBJ_TYPE => 'myns:complex'; use constant OBJ_URI => 'http://my.uri.com'; use constant OBJ_FIELDS => { string_array => [ 'SOAP-ENC:Array', undef, { 'SOAP-ENC:arrayType' => 'string +' } ] }; sub new { my $proto = shift; my $class = ref($proto) || $proto; my $data = shift; my $obj_fields = $_[1]; #second param from untouched @_ $obj_fields = defined $obj_fields && ref($obj_fields) eq 'HASH' ? +{%{+OBJ_FIELDS}, %{$obj_fields}} : OBJ_FIELDS; my $self = $class->SUPER::new($data, $obj_fields); return bless($self, $class); } my $complex = My::Complex->new({string_array => [ 'text1', 'text2', 't +ext3' ]}); print $complex->as_xml_data;
I was expecting output like
<string_array type="xsi:SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string +[3]"> <item xsi:type="xsd:string">text1</item> <item xsi:type="xsd:string">text2</item> <item xsi:type="xsd:string">text3</item> </string_array>
but all I got was three <string_array>s. I'm using SOAP::Data::ComplexType 0.044 running on ActivePerl. Please tell me what kind of mistake I've made...

In reply to SOAP array construction with SOAP::Data::ComplexType by takeos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.