3 Replies Latest reply on Aug 9, 2006 1:00 PM by aBill

    SOAP parameter serialization

      Hi all,

      I'm looking for some information on how Flash/Flex serializes parameters to WebService operations. If a web service operations takes a simple parameter like a string, I can just pass it in as the argument to the Operation.send() method but what if the parameter is a "complexType"? Do I need to create an xml node or just an object with public properties, etc...?

      Any info on this would be much appreciated.

        • 1. Re: SOAP parameter serialization
          aBill Level 1

          For complex type you can pass the parameter in object. for example:
          WSDL type definition
          <complexType name="SOAPStruct">
          <element name="varString" nillable="true" type="xsd:string" />
          <element name="varInt" type="xsd:int" />
          <element name="varFloat" type="xsd:float" />

          _service.echoStruct({varString:'The String', varInt:245, varFloat:2134.123});
          or pass it through from tag declarion: for example
          <mx:operation name="echoStruct" result="onResult(event)" fault="onFault(event)">
          <mx:request format="object">
          <varString>The String</varString>

          and you can also construct it as xml, for example
          <mx:request format="xml">
          <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
          <key xsi:type="xsd:string">00000000000000000000000000000000</key>
          <q xsi:type="xsd:string">{ti_searchparm.text}</q>
          <start xsi:type="xsd:int">0</start>
          <maxResults xsi:type="xsd:int">10</maxResults>
          <filter xsi:type="xsd:boolean">true</filter>
          <restrict xsi:type="xsd:string" />
          <safeSearch xsi:type="xsd:boolean">false</safeSearch>
          <lr xsi:type="xsd:string" />
          <ie xsi:type="xsd:string">latin1</ie>
          <oe xsi:type="xsd:string">latin1</oe>

          Hope the above info help! Thanks!
          William Chan
          • 2. Re: SOAP parameter serialization
            rmarp Level 1
            William - Thank you, this is helpful. One other thing though.. a few of the web service operations I need to call have a parameter defined like this:

            <complexType name="Account">
            <attribute name="Name" type="string" use="required"/>
            <attribute name="Value" type="string" use="required"/>

            Notice that the Name and Value items are attributes, not sub-elements. If I create an object like:

            var param:Object = {Name:"xxxx", Value:"yyyy"};

            is there a way to have these properties encoded as attributes as opposed to sub-elements?

            • 3. Re: SOAP parameter serialization
              aBill Level 1
              Ryan - you can just pass the object, flex does take care where it is element or attribute

              following is the sample(one of testcase we have)
              <s:complexType name="Person">
              <s:element minOccurs="1" maxOccurs="1" name="Age" type="s:double" />
              <s:element minOccurs="1" maxOccurs="1" name="ID" type="s:float" />
              <s:attribute name="Name" type="s:string" />
              <s:attribute name="Male" type="s:boolean" />

              var expected:Object = new Object();
              expected.Name = "Bob Smith";
              expected.Male = true;
              expected.Age = 31;
              expected.ID = 12345;