1 Reply Latest reply on Sep 2, 2011 12:17 PM by SteveTX

    Formatting CF data for a web service complex type

    SteveTX Level 1

      I am trying to call a web service with the following definition in the WSDL

       

      <s:element name="CreateDataList">

           <s:complexType>

                <s:sequence>

                     <s:element minOccurs="0" maxOccurs="1" name="client_app_id" type="s:string"/>

                     <s:element minOccurs="0" maxOccurs="1" name="client_app_pwd" type="s:string"/>

                     <s:element minOccurs="1" maxOccurs="1" name="data_template_id" type="s:int"/>

                     <s:element minOccurs="1" maxOccurs="1" name="calculate_persistent_values" type="s:int"/>

                     <s:element minOccurs="0" maxOccurs="1" name="data" type="tns:ArrayOfArrayOfName_value"/>

                </s:sequence>

           </s:complexType>

      </s:element>

      <s:complexType name="ArrayOfArrayOfName_value">

           <s:sequence>

                <s:element minOccurs="0" maxOccurs="unbounded" name="record" type="tns:ArrayOfName_value"/>

           </s:sequence>

      </s:complexType>

      <s:complexType name="ArrayOfName_value">

           <s:sequence>

                <s:element minOccurs="0" maxOccurs="unbounded" name="variable" type="tns:name_value"/>

           </s:sequence>

      </s:complexType>

      <s:complexType name="name_value">

           <s:sequence>

                <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string"/>

                <s:element minOccurs="0" maxOccurs="1" name="value" type="s:string"/>

           </s:sequence>

      </s:complexType>

       

      I am trying to format the ArrayOfArrayOfName_value data and getting an "argument type mismatch" error. The sample PHP code for the data looks like this:

       

      $data = array(0 => array(
          array('name' => 'FIRST_NAME', 'value' => 'First'),
          array('name' => 'LAST_NAME', 'value' => 'Last'),
          array('name' => 'ADDRESS', 'value' => 'Address'),
          array('name' => 'CITY', 'value' => 'City'),
          array('name' => 'STATE', 'value' => 'State'),
          array('name' => 'ZIP', 'value' => '55555')
          ),                       
      1 => array(
          array('name' => 'FIRST_NAME', 'value' => 'First'),
          array('name' => 'LAST_NAME', 'value' => 'Last'),
          array('name' => 'ADDRESS', 'value' => 'Address'),
          array('name' => 'CITY', 'value' => 'City'),
          array('name' => 'STATE', 'value' => 'State'),
          array('name' => 'ZIP', 'value' => '55555')
          ));

       

      My CF code looks like this:

       

      <cfset data = ArrayNew(1) />

       

      <cfset data[1] = ArrayNew(1) />
      <cfset data[1][1] = StructNew() />
      <cfset data[1][1]["name"] = "NAME" />
      <cfset data[1][1]["value"] = "JOhn Doe" />
      <cfset data[1][2] = StructNew() />
      <cfset data[1][2]["name"] = "ADDRESS1" />
      <cfset data[1][2]["value"] = "123 Test St" />
      <cfset data[1][3] = StructNew() />
      <cfset data[1][3]["name"] = "ADDRESS2" />
      <cfset data[1][3]["value"] = "" />
      <cfset data[1][4] = StructNew() />
      <cfset data[1][4]["name"] = "CITY" />
      <cfset data[1][4]["value"] = "Austin" />
      <cfset data[1][5] = StructNew() />
      <cfset data[1][5]["name"] = "STATE" />
      <cfset data[1][5]["value"] = "TX" />
      <cfset data[1][6] = StructNew() />
      <cfset data[1][6]["name"] = "ZIP" />
      <cfset data[1][6]["value"] = "78704" />

       

      <cfset data[2] = ArrayNew(1) />
      <cfset data[2][1] = StructNew() />
      <cfset data[2][1]["name"] = "NAME" />
      <cfset data[2][1]["value"] = "Jane Doe" />
      <cfset data[2][2] = StructNew() />
      <cfset data[2][2]["name"] = "ADDRESS1" />
      <cfset data[2][2]["value"] = "987 Test St" />
      <cfset data[2][3] = StructNew() />
      <cfset data[2][3]["name"] = "ADDRESS2" />
      <cfset data[2][3]["value"] = "" />
      <cfset data[2][4] = StructNew() />
      <cfset data[2][4]["name"] = "CITY" />
      <cfset data[2][4]["value"] = "Austin" />
      <cfset data[2][5] = StructNew() />
      <cfset data[2][5]["name"] = "STATE" />
      <cfset data[2][5]["value"] = "TX" />
      <cfset data[2][6] = StructNew() />
      <cfset data[2][6]["name"] = "ZIP" />
      <cfset data[2][6]["value"] = "78704" />

       

      Any suggestions for where I am going wrong would be greatly appreciated.

        • 1. Re: Formatting CF data for a web service complex type
          SteveTX Level 1

          If anyone is interested here is the correct CF format for this WSDL complex type definition

           

          <cfset data = StructNew() />
          <cfset data["record"] = ArrayNew(1) />

           

          <cfset data["record"][1] = StructNew() />
          <cfset data["record"][1]["variable"] = ArrayNew(1) />
          <cfset data["record"][1]["variable"][1] = StructNew() />
          <cfset data["record"][1]["variable"][1]["name"] = "NAME" />
          <cfset data["record"][1]["variable"][1]["value"] = "John Doe" />

           

          <cfset data["record"][1]["variable"][2] = StructNew() />
          <cfset data["record"][1]["variable"][2]["name"] = "ADDRESS1" />
          <cfset data["record"][1]["variable"][2]["value"] = "123 Test St" />

           

          <cfset data["record"][1]["variable"][3] = StructNew() />
          <cfset data["record"][1]["variable"][3]["name"] = "ADDRESS2" />
          <cfset data["record"][1]["variable"][3]["value"] = "" />

           

          <cfset data["record"][1]["variable"][4] = StructNew() />
          <cfset data["record"][1]["variable"][4]["name"] = "CITY" />
          <cfset data["record"][1]["variable"][4]["value"] = "Austin" />

           

          <cfset data["record"][1]["variable"][5] = StructNew() />
          <cfset data["record"][1]["variable"][5]["name"] = "STATE" />
          <cfset data["record"][1]["variable"][5]["value"] = "TX" />

           

          <cfset data["record"][1]["variable"][6] = StructNew() />
          <cfset data["record"][1]["variable"][6]["name"] = "ZIP" />
          <cfset data["record"][1]["variable"][6]["value"] = "78704" />

           

          <cfset data["record"][2] = StructNew() />
          <cfset data["record"][2]["variable"] = ArrayNew(1) />
          <cfset data["record"][2]["variable"][1] = StructNew() />
          <cfset data["record"][2]["variable"][1]["name"] = "NAME" />
          <cfset data["record"][2]["variable"][1]["value"] = "Jane Doe" />

           

          <cfset data["record"][2]["variable"][2] = StructNew() />
          <cfset data["record"][2]["variable"][2]["name"] = "ADDRESS1" />
          <cfset data["record"][2]["variable"][2]["value"] = "987 Test St" />

           

          <cfset data["record"][2]["variable"][3] = StructNew() />
          <cfset data["record"][2]["variable"][3]["name"] = "ADDRESS2" />
          <cfset data["record"][2]["variable"][3]["value"] = "" />

           

          <cfset data["record"][2]["variable"][4] = StructNew() />
          <cfset data["record"][2]["variable"][4]["name"] = "CITY" />
          <cfset data["record"][2]["variable"][4]["value"] = "Austin" />

           

          <cfset data["record"][2]["variable"][5] = StructNew() />
          <cfset data["record"][2]["variable"][5]["name"] = "STATE" />
          <cfset data["record"][2]["variable"][5]["value"] = "TX" />

           

          <cfset data["record"][2]["variable"][6] = StructNew() />
          <cfset data["record"][2]["variable"][6]["name"] = "ZIP" />
          <cfset data["record"][2]["variable"][6]["value"] = "78704" />