Hi i'm experiencing some strange bug similar to this very old PHP Bug:
https://bugs.php.net/bug.php?id=48966
Only difference: i'm using using the classmap function of php's soap-client.
Looks something like this:
class Client extends \SoapClient
{
//left something out here
const DOMAIN_MODEL_NAMESPACE = 'Domain\\Model\\';
/**
* @return array
*/
private function getClassmap()
{
return array(
'AddressCheck' => self::DOMAIN_MODEL_NAMESPACE . 'AddressCheck\\AddressCheckRequest',
'AddressCheckResponse' => self::DOMAIN_MODEL_NAMESPACE . 'AddressCheck\\AddressCheckResponse',
'matchingAddresses' => self::DOMAIN_MODEL_NAMESPACE . 'AddressCheck\\MatchingAddresses',
'address' => self::DOMAIN_MODEL_NAMESPACE . 'Common\\Address',
'RequestHeader' => self::DOMAIN_MODEL_NAMESPACE . 'Common\\Header\\RequestHeader',
'salesOrderEntry' => self::DOMAIN_MODEL_NAMESPACE . 'Common\\Header\\SalesOrderEntry'
);
}
/**
* @param Configuration\ConfigurationInterface $configuration
* @param string $wsdl
*/
public function __construct($wsdl, Configuration\ConfigurationInterface $configuration)
{
$options = array(
'classmap' => $this->getClassmap(),
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'location' => $configuration->getServiceLocation(),
'trace' => 1,
'soap_version' => SOAP_1_1,
'exceptions' => 1,
'cache_wsdl' => 0
);
parent::__construct($wsdl, $options);
}
}
Other Class:
$address = new Common\Address($street, $houseNumber, $postalCode, $city);
$request = new AddressCheck\AddressCheckRequest($address);
$response = $this->soapClient->__soapCall($requestName, array($request));
This is generated by wsdl2PHP but then modified a bit to fit in PSR-4 Autoloading.
My problem lies in the generated XML Request:
Should be (generated by SOAPUi!): -> looks like SOAP_1_1 to me. (correct?)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.aax2.compax.at">
<soapenv:Header/>
<soapenv:Body>
<web:AddressCheck>
<web:header>
<web:source>1</web:source>
<web:version>1.11</web:version>
<web:client>1</web:client>
<web:testing>0</web:testing>
<web:salesOrderEntry>
<web:partnerId>300011489</web:partnerId>
<web:distributionChannelId>300000011</web:distributionChannelId>
</web:salesOrderEntry>
</web:header>
<web:address>
<web:street>SomeStreet</web:street>
<web:houseNumber>6</web:houseNumber>
<web:zip>66666</web:zip>
<web:city>SomeCity</web:city>
</web:address>
</web:AddressCheck>
</soapenv:Body>
</soapenv:Envelope>
Is (Generated by soap-client):
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="http://webservices.aax2.compax.at">
<SOAP-ENV:Body>
<ns1:AddressCheck>
<header>
<source>1</source>
<version>1.11</version>
<client>1</client>
<testing>0</testing>
<salespartnerData xsi:nil="true"/>
<salesOrderEntry>
<partnerId>300011489</partnerId>
<distributionChannelId>300000011</distributionChannelId>
</salesOrderEntry>
<last_user xsi:nil="true"/>
<timeOfCall xsi:nil="true"/>
<clientIP xsi:nil="true"/>
<orderContext xsi:nil="true"/>
<scanId xsi:nil="true"/>
</header>
<address>
<street>SomeStreet</street>
<houseNumber>6</houseNumber>
<zip>66666</zip>
<city>SomeCity</city>
<buildingType xsi:nil="true"/>
<buildingPart xsi:nil="true"/>
<buildingPartNotes xsi:nil="true"/>
<buildingPartDetail xsi:nil="true"/>
<floor xsi:nil="true"/>
<notes xsi:nil="true"/>
<noOfCorrections xsi:nil="true"/>
</address>
</ns1:AddressCheck>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can see the prefix of the nested nodes is missing. The documentation of the soap-client is extremly thin, but I dont want to generate or manipulate the XML by hand because the WSDL is gigantic!
What exactly could be configured wrong in the WSDL? If you need I can provide those informations, too. But not the whole WSDL.
It seems to me that the classmap isn't used at all.. (typo maybe?) But I have no clue how to debug the classmap?!