Remove from response the nillable elements. Fix namespace declaration in the xml response
This commit is contained in:
parent
9fc58e4388
commit
fea1093bed
@ -99,7 +99,30 @@ class SoapServer extends \SoapServer
|
||||
ob_start();
|
||||
parent::handle($soapRequest->getContent());
|
||||
$response = ob_get_clean();
|
||||
$response = str_replace('SOAP-ENV', 'soap', $response);
|
||||
|
||||
$dom = \DOMDocument::loadXML($response);
|
||||
|
||||
/** @var \DOMElement $envelop */
|
||||
$envelop = $dom->childNodes->item(0);
|
||||
$ns1 = $envelop->getAttribute('xmlns:ns1');
|
||||
$envelop->removeAttributeNS($ns1, 'ns1');
|
||||
$envelop->prefix = 'soap';
|
||||
|
||||
$envelop->setAttribute('soap:encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/');
|
||||
$envelop->setAttribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/');
|
||||
$envelop->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
|
||||
|
||||
/** @var \DOMElement $body */
|
||||
$body = $envelop->childNodes->item(0);
|
||||
$body->prefix = 'soap';
|
||||
|
||||
/** @var \DOMElement $responseRoot */
|
||||
$responseRoot = $body->childNodes->item(0);
|
||||
$responseRoot->setAttribute('xmlns', $ns1);
|
||||
|
||||
$envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV');
|
||||
|
||||
$response = $dom->saveXML();
|
||||
|
||||
// Remove headers added by SoapServer::handle() method
|
||||
header_remove('Content-Length');
|
||||
|
@ -277,7 +277,7 @@ class Dumper
|
||||
}
|
||||
|
||||
if ($child->isNillable()) {
|
||||
$element->setAttribute('nillable', 'true');
|
||||
$element->setAttribute('minOccurs', 0);
|
||||
}
|
||||
|
||||
if ($type instanceof ArrayOfType || $isArray) {
|
||||
|
Loading…
Reference in New Issue
Block a user