diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 92237db..88a595e 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -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'); diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index 9121ff9..5e2ae46 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -277,7 +277,7 @@ class Dumper } if ($child->isNillable()) { - $element->setAttribute('nillable', 'true'); + $element->setAttribute('minOccurs', 0); } if ($type instanceof ArrayOfType || $isArray) {