Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:34:38+00:00 2026-05-20T22:34:38+00:00

I am building a web service using php core SOAP classes, and need to

  • 0

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:

<xsd:simpleType name="ErrorCodeEnum">
        <xsd:restriction base="xsd:string">
          <xsd:enumeration value="OK"/>
          <xsd:enumeration value="INTERNAL_ERROR"/>
          <xsd:enumeration value="TOO_MANY_REQUESTS"/>
        </xsd:restriction>
</xsd:simpleType>

server.php:

<?php
class testclass {
   public function testfunc($param) {
      $resp = new testResp();
      $resp->errorCode = 'OK'; #SoapServer returns xsd:string type.
      return $resp;
   }
}

class testReq {}

class testResp {
   public $errorCode;
}

$class_map = array('testReq' => 'testReq', 'testResp' => 'testResp');
$server = new SoapServer (null, array('uri' => 'http://test-uri/', 'classmap' => $class_map));
$server->setClass ("testclass");
$server->handle();
?>

Answer:

<ns1:testResponse>
     <return xsi:type="SOAP-ENC:Struct">
        <errorCode xsi:type="xsd:string">OK</errorCode>
     </return>
</ns1:testResponse>

How can i do to return type ErrorCodeEnum instead of string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:34:39+00:00Added an answer on May 20, 2026 at 10:34 pm

    I solved it. There was some problem about server not loading the WSDL file. This is the types section in the WSDL:

    <wsdl:types>
       <xsd:schema targetNamespace="http://schema.example.com">
          <xsd:simpleType name="ErrorCodeEnum">
             <xsd:restriction base="xsd:string">
                <xsd:enumeration value="OK"/>
                <xsd:enumeration value="INTERNAL_ERROR"/>
                <xsd:enumeration value="TOO_MANY_REQUESTS"/>
             </xsd:restriction>
          </xsd:simpleType>
          <xsd:complexType name="testResp">
             <xsd:all>
                <xsd:element name="errorCode" type="xsd:ErrorCodeEnum"/>
             </xsd:all>
          </xsd:complexType>
       </xsd:schema>
    </wsdl:types>
    

    Actual server answer:

    <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schema.example.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
       <SOAP-ENV:Body>
          <ns1:testResponse>
             <testReturn xsi:type="ns1:testResp">
                <errorCode xsi:type="xsd:ErrorCodeEnum">OK</errorCode>
             </testReturn>
          </ns1:testResponse>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on building a web service (using c#) and this web service
I am building a web service using WCF. This service has to support REST.
I'm building a web service client using vb .net. The web service is secured
I am building a RESTful web service in java using JAX-RS and jersey and
I'm building a restful web-service based on Spring. I'm using Spring Security. It will
I am building a web service using the Zend Framework. I am using the
I am building a web application with PHP/MySQL using the Yii framework. Key aspect
I am building a Web service using Java and Spring-ws. It is working fine,
I'm building a web service using Flask and I'm trying to deploy a simple
I was doing some reading up on building a soap service using jax-ws as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.