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.
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???