title: How to format Yii2 Soap Server Response same as my Old Php Soap Service
body: <p>Sorry about my English. I am trying to rebuild my old soap server on Yii2.</p>
  
  <p>I couldn't format the element names same as old service response.</p>
  
  <p>How can i do it?</p>
  
  <p>The old service response is</p>
  
  <pre><code>   &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.xxx.com"&gt;
     &lt;SOAP-ENV:Body&gt;
        &lt;ns1:GetAllColorsResponse&gt;
           &lt;describedColorArray&gt;
              &lt;DescribedColor&gt;
                 &lt;id&gt;6&lt;/id&gt;
                 &lt;Name&gt;beyaz&lt;/Name&gt;
                 &lt;HTMLColorCode&gt;#000000&lt;/HTMLColorCode&gt;
              &lt;/DescribedColor&gt;
              &lt;DescribedColor&gt;
                 &lt;id&gt;2&lt;/id&gt;
                 &lt;Name&gt;kırmızı&lt;/Name&gt;
                 &lt;HTMLColorCode&gt;#FF0000&lt;/HTMLColorCode&gt;
              &lt;/DescribedColor&gt;
              &lt;DescribedColor&gt;
                 &lt;id&gt;4&lt;/id&gt;
                 &lt;Name&gt;mavi&lt;/Name&gt;
                 &lt;HTMLColorCode&gt;#0000FF&lt;/HTMLColorCode&gt;
              &lt;/DescribedColor&gt;
              &lt;DescribedColor&gt;
                 &lt;id&gt;1&lt;/id&gt;
                 &lt;Name&gt;sarı&lt;/Name&gt;
                 &lt;HTMLColorCode&gt;#909000&lt;/HTMLColorCode&gt;
              &lt;/DescribedColor&gt;
              &lt;DescribedColor&gt;
                 &lt;id&gt;3&lt;/id&gt;
                 &lt;Name&gt;turuncu&lt;/Name&gt;
                 &lt;HTMLColorCode&gt;#FF9900&lt;/HTMLColorCode&gt;
              &lt;/DescribedColor&gt;
              &lt;DescribedColor&gt;
                 &lt;id&gt;5&lt;/id&gt;
                 &lt;Name&gt;yeşil&lt;/Name&gt;
                 &lt;HTMLColorCode&gt;#009000&lt;/HTMLColorCode&gt;
              &lt;/DescribedColor&gt;
           &lt;/describedColorArray&gt;
        &lt;/ns1:GetAllColorsResponse&gt;
     &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>Yii2 soap service response is</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://newapi.xxx.com/api/GetAllColors?ws=1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
     &lt;SOAP-ENV:Body&gt;
        &lt;ns1:GetAllColorsResponse&gt;
           &lt;return xsi:type="ns2:Map"&gt;
              &lt;item&gt;
                 &lt;key xsi:type="xsd:string"&gt;describedColorArray&lt;/key&gt;
                 &lt;value xsi:type="ns2:Map"&gt;
                    &lt;item&gt;
                       &lt;key xsi:type="xsd:string"&gt;DescribedColor&lt;/key&gt;
                       &lt;value SOAP-ENC:arrayType="ns2:Map[6]" xsi:type="SOAP-ENC:Array"&gt;
                          &lt;item xsi:type="ns2:Map"&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;id&lt;/key&gt;
                                &lt;value xsi:type="xsd:int"&gt;6&lt;/value&gt;
                             &lt;/item&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;name&lt;/key&gt;
                                &lt;value xsi:type="xsd:string"&gt;beyaz&lt;/value&gt;
                             &lt;/item&gt;
                          &lt;/item&gt;
                          &lt;item xsi:type="ns2:Map"&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;id&lt;/key&gt;
                                &lt;value xsi:type="xsd:int"&gt;2&lt;/value&gt;
                             &lt;/item&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;name&lt;/key&gt;
                                &lt;value xsi:type="xsd:string"&gt;kırmızı&lt;/value&gt;
                             &lt;/item&gt;
                          &lt;/item&gt;
                          &lt;item xsi:type="ns2:Map"&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;id&lt;/key&gt;
                                &lt;value xsi:type="xsd:int"&gt;4&lt;/value&gt;
                             &lt;/item&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;name&lt;/key&gt;
                                &lt;value xsi:type="xsd:string"&gt;mavi&lt;/value&gt;
                             &lt;/item&gt;
                          &lt;/item&gt;
                          &lt;item xsi:type="ns2:Map"&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;id&lt;/key&gt;
                                &lt;value xsi:type="xsd:int"&gt;1&lt;/value&gt;
                             &lt;/item&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;name&lt;/key&gt;
                                &lt;value xsi:type="xsd:string"&gt;sarı&lt;/value&gt;
                             &lt;/item&gt;
                          &lt;/item&gt;
                          &lt;item xsi:type="ns2:Map"&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;id&lt;/key&gt;
                                &lt;value xsi:type="xsd:int"&gt;3&lt;/value&gt;
                             &lt;/item&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;name&lt;/key&gt;
                                &lt;value xsi:type="xsd:string"&gt;turuncu&lt;/value&gt;
                             &lt;/item&gt;
                          &lt;/item&gt;
                          &lt;item xsi:type="ns2:Map"&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;id&lt;/key&gt;
                                &lt;value xsi:type="xsd:int"&gt;5&lt;/value&gt;
                             &lt;/item&gt;
                             &lt;item&gt;
                                &lt;key xsi:type="xsd:string"&gt;name&lt;/key&gt;
                                &lt;value xsi:type="xsd:string"&gt;yeşil&lt;/value&gt;
                             &lt;/item&gt;
                          &lt;/item&gt;
                       &lt;/value&gt;
                    &lt;/item&gt;
                 &lt;/value&gt;
              &lt;/item&gt;
           &lt;/return&gt;
        &lt;/ns1:GetAllColorsResponse&gt;
     &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>Yii2 Controller Code is</p>
  
  <pre><code>public function actions()
  {
      return [
          'GetAllColors' =&gt; [
              'class' =&gt; 'mongosoft\soapserver\Action',
              'serviceOptions' =&gt; [
                  'disableWsdlMode' =&gt; true,
              ]
          ]
      ];
  }
  
  /**
   * @return array
   * @soap
   */
  public function GetAllColors()
  {
      $model = GeneralColor::find()-&gt;orderBy('name')-&gt;asArray()-&gt;all();
      foreach($model as $m){
          $row['id'] = $m['id'];
          $row['name'] = $m['name'];
  
          $rows['describedColorArray']['DescribedColor'][] = $row;
      }
      return $rows;
  }
  </code></pre>