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

Complex types help

Expand Messages
  • malcolmpdx
    I m certain that buried somewhere in the archives there is the answer to my question, but so far, I ve been unable to find it, at least in the form that I can
    Message 1 of 2 , Mar 17 2:01 PM
    • 0 Attachment
      I'm certain that buried somewhere in the archives there is the answer to my question, but so far, I've been unable to find it, at least in the form that I can understand.

      I'm porting some code that uses SOAP::Lite to interface with a SOAP interface to a CRM system. Generally speaking, this is going well, and I've been able to get the various chunks of XML that are required by the various calls to work just fine. But when confronted with this spec (from the wsdl for the service)

      <xsd:complexType name="name_value_list">

      <xsd:complexContent>

      <xsd:restriction base="SOAP-ENC:Array">
      <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:name_value[]"/>
      </xsd:restriction>
      </xsd:complexContent>
      </xsd:complexType>

      I have hit a real block. The eventual output I need to have sent looks like this:

      <name_value_list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:name_value[1]">
      <item xsi:type="tns:name_value">
      <name xsi:type="xsd:string">modified_by_name</name>
      <value xsi:type="xsd:string">admin</value>
      </item>
      </name_value_list>

      And, after days of trying to get this to work, I've come to the end of my rope. Perhaps someone else would be so kind as to give me a clue.

      Thanks,

      Malcolm
    • rahed
      ... Try this, it should generate exactly the same structure. $SOAP::Constants::PREFIX_ENC = SOAP-ENC ; @data = ( [ modified_by_name , admin ], );
      Message 2 of 2 , Mar 19 6:26 AM
      • 0 Attachment
        "malcolmpdx" <malcolmpdx@...> writes:

        > I have hit a real block. The eventual output I need to have sent looks like this:
        >
        > <name_value_list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:name_value[1]">
        > <item xsi:type="tns:name_value">
        > <name xsi:type="xsd:string">modified_by_name</name>
        > <value xsi:type="xsd:string">admin</value>
        > </item>
        > </name_value_list>

        Try this, it should generate exactly the same structure.


        $SOAP::Constants::PREFIX_ENC = 'SOAP-ENC';

        @data = (
        ['modified_by_name','admin'],
        );
        $soap->serializer->register_ns('http://my.namespace1'=>'xmlns:tns');

        for my $item (@data) {
        push @name_value, SOAP::Data->name('item')->type('tns:name_value'=>\SOAP::Data->value(
        SOAP::Data->name(name => $item->[0])->type('string'),
        SOAP::Data->name(value => $item->[1])->type('string'),
        ),
        );
        }

        And object to send:

        $object = SOAP::Data->name('name_value_list')->type('SOAP-ENC:Array'=>\@name_value);

        hth

        --
        Radek
      Your message has been successfully submitted and would be delivered to recipients shortly.