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 3225820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:23:01+00:00 2026-05-17T16:23:01+00:00

I’ve encountered a few different WSDL files that contain an element and a complexType

  • 0

I’ve encountered a few different WSDL files that contain an element and a complexType with the same name. For example, http://soap.search.msn.com/webservices.asmx?wsdl has two entities named “SearchResponse”:

In this scenario, I can’t figure out how to properly map those entities to PHP classes using the SoapClient() “classmaps” option.

The PHP manual says this:

The classmap option can be used to map
some WSDL types to PHP classes. This
option must be an array with WSDL
types as keys and names of PHP classes
as values.

Unfortunately, since there are two WSDL types with the same key (‘SearchResponse’), I can’t figure out how to differentiate between the two SearchResponse entities and assign them to their corresponding PHP classes.

For example, here is the relevant snippet of the example WSDL:

<xsd:complexType name="SearchResponse">
    <xsd:sequence>
        <xsd:element minOccurs="1" maxOccurs="1" name="Responses" type="tns:ArrayOfSourceResponseResponses"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:element name="SearchResponse">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element minOccurs="1" maxOccurs="1" name="Response" type="tns:SearchResponse"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

And here is the PHP that obviously would not work since the classmaps keys are the same:

<?php $server = new SoapClient("http://soap.search.msn.com/webservices.asmx?wsdl", array('classmap' => array('SearchResponse' => 'MySearchResponseElement', 'SearchResponse' => 'MySearchResponseComplexType'))); ?>

In searching for a solution, I found Java Web Services handles this by allowing you to specify a custom suffix to the “Element” or “ComplexType” entities.

http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.5/tutorial/doc/JAXBUsing4.html#wp149350

So, right now I feel like there is just no way to do it with PHP’s SoapClient, but I’m curious if anyone out there can offer any advice. FWIW, I cannot edit the remote WDSL.

Any ideas???

  • 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-17T16:23:02+00:00Added an answer on May 17, 2026 at 4:23 pm

    This is off the top of my head, but I think you could have both SearchResponse types map to MY_SearchResponse and try and abstract the difference between the two. It’s kludgy, but something like this maybe?

    <?php
    //Assuming SearchResponse<complexType> contains SearchReponse<element> which contains and Array of SourceResponses
    //You could try abstracting the nested Hierarchy like so:
    class MY_SearchResponse
    {
       protected $Responses;
       protected $Response;
    
       /**
        * This should return the nested SearchReponse<element> as a MY_SearchRepsonse or NULL
        **/
       public function get_search_response()
       {
          if($this->Response && isset($this->Response))
          {
             return $this->Response; //This should also be a MY_SearchResponse
          }
          return NULL;
       }
    
       /**
        * This should return an array of SourceList Responses or NULL
        **/
       public function get_source_responses()
       {
          //If this is an instance of the top SearchResponse<complexType>, try to get the SearchResponse<element> and it's source responses
          if($this->get_search_response() && isset($this->get_search_response()->get_source_responses()))
          {
             return $this->get_search_response()->get_source_responses();
          }
          //We are already the nested SearchReponse<element> just go directly at the Responses
          elseif($this->Responses && is_array($this->Responses)
          {
             return $this->Responses;
          }
          return NULL;
       }
    }
    
    class MY_SourceResponse
    {
      //whatever properties SourceResponses have
    }
    
    $client = new SoapClient("http:/theurl.asmx?wsdl", array('classmap' => array('SearchResponse' => 'MY_SearchResponse', 'SourceResponse' => 'MY_SourceResponse')));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.