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

  • SEARCH
  • Home
  • 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 6620645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:07:43+00:00 2026-05-25T21:07:43+00:00

Is there a way to return in soap an object with his methods? If

  • 0

Is there a way to return in soap an object with his methods? If i return xsd:struct in WSDL i only get the properties of the object but i can’t use any of the methods.

For example

class person
{
  var $name = "My name";
  public function getName()
  {
      return $this->name;
  }
}

So after fetching the object:

$client = new SoapClient();
$person = $client->getPerson();
echo $person->getName(); // Return "My Name";

Thanks.

  • 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-25T21:07:44+00:00Added an answer on May 25, 2026 at 9:07 pm

    You cannot do this with SOAP. Basically your PHP class is being mapped to an XML data structure that’s defined by an XML schema. This mapping only includes properties and cannot include executable code. SOAP is designed for interoperability and naturally you cannot share code between, let’s say, PHP and Java or .NET. On the receiving side your XML data structure is being transformed into a data structure of the client’s programming language (a PHP class if you use SoapClient or a C# class if you use C#). As the XML data structure only carries property information the executable part of the originating class cannot be rebuilt.

    But there is one thing that can help if both the SOAP server and the connecting client have access to the same code base (which means the same classes). You can define a mapping between a XML type and a PHP class in the SoapClient‘s constructor using the classmap-option. This allows SoapClient to map incoming XML data structures to real PHP classes – given the fact that both the server and the client have access to the relevant class definition. This allows you to use methods on the receiving side of the SOAP communication.

    class book {
        public $a = "a";
        public $b = "c";
        public function getName() {
            return $this->a.' '.$this->b;
        }
    }
    
    $options = array(
        'classmap' => array('book' => 'book')
    );
    $client = new SoapClient('path/to/wsdl', $options);
    $book    = $client->test();
    echo $book->getName();
    

    The WSDL might look like (copied from one of the SoapClient tests and adpated):

    <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.nothing.com" targetNamespace="http://schemas.nothing.com">
        <wsdl:types>
            <xsd:schema targetNamespace="http://schemas.nothing.com">
                <xsd:complexType name="book">
                    <xsd:all>
                        <xsd:element name="a" type="xsd:string"/>
                        <xsd:element name="b" type="xsd:string"/>
                    </xsd:all>
                </xsd:complexType>
      </xsd:schema>
        </wsdl:types>
        <message name="testRequest">
        </message>
        <message name="testResponse">
            <part name="res" type="tns:book"/>
      </message>
        <portType name="testPortType">
            <operation name="test">
                <input message="tns:testRequest"/>
                <output message="tns:testResponse"/>
            </operation>
        </portType>
        <binding name="testBinding" type="tns:testPortType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="test">
                <soap:operation soapAction="http://localhost:81/test/interface.php?class=test/dotest" style="rpc"/>
                <input>
                    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.nothing.com"/>
                </input>
                <output>
                    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.nothing.com"/>
                </output>
            </operation>
        </binding>
        <service name="test">
            <port name="testPort" binding="tns:testBinding">
                <soap:address location="http://localhost:81/test/interface.php?class=test"/>
            </port>
        </service>
    </wsdl:definitions>
    

    The State of SOAP in PHP might be interesting if you’re doing SOAP in PHP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to return a random row from a table using LINQToSQL?
Is there any way to return an array from a function? More specifically, I've
Is there a way to return a point for a string within a text
Is there a way to return a new version of an array/hash that does
Instead of returning a common string, is there a way to return classic objects?
Is there an easy way to return data to web service clients in JSON
Is there a preferred way to return multiple values from a C++ function? For
Is there a (simple) way to return the amount of elements colliding with a
I would like to know if there is any way to return an char
Hope this makes sense... Is there a simple way to return a set of

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.