title: How to return an enumerated type in a PHP SOAP Server
body: <p>I am building a web service using php core SOAP classes, and need to return a variable of enumerated type. This is the type definition in WSDL:</p>
  
  <pre><code>&lt;xsd:simpleType name="ErrorCodeEnum"&gt;
          &lt;xsd:restriction base="xsd:string"&gt;
            &lt;xsd:enumeration value="OK"/&gt;
            &lt;xsd:enumeration value="INTERNAL_ERROR"/&gt;
            &lt;xsd:enumeration value="TOO_MANY_REQUESTS"/&gt;
          &lt;/xsd:restriction&gt;
  &lt;/xsd:simpleType&gt;
  </code></pre>
  
  <p>server.php:</p>
  
  <pre><code>&lt;?php
  class testclass {
     public function testfunc($param) {
        $resp = new testResp();
        $resp-&gt;errorCode = 'OK'; #SoapServer returns xsd:string type.
        return $resp;
     }
  }
  
  class testReq {}
  
  class testResp {
     public $errorCode;
  }
  
  $class_map = array('testReq' =&gt; 'testReq', 'testResp' =&gt; 'testResp');
  $server = new SoapServer (null, array('uri' =&gt; 'http://test-uri/', 'classmap' =&gt; $class_map));
  $server-&gt;setClass ("testclass");
  $server-&gt;handle();
  ?&gt;
  </code></pre>
  
  <p>Answer:</p>
  
  <pre><code>&lt;ns1:testResponse&gt;
       &lt;return xsi:type="SOAP-ENC:Struct"&gt;
          &lt;errorCode xsi:type="xsd:string"&gt;OK&lt;/errorCode&gt;
       &lt;/return&gt;
  &lt;/ns1:testResponse&gt;
  </code></pre>
  
  <p>How can i do to return type <code>ErrorCodeEnum</code> instead of <code>string</code>?</p>