Setting a custom SoapServer response namespace

I am creating a Soap server.

Is there a way to change the default namespace for soap wrappers, body tags, and headers?

To continue the query, I use the following code:

ini_set( "soap.wsdl_cache_enabled", "0");
$server = new SoapServer('myWsdl.wsdl');
$server->addFunction("GetDetails");
$server->handle();

function GetDetails(){
    $body_xml = '<GetDetailsResponse>
                    <Name>My name</Name>
                 </GetDetailsResponse>';
    $result = new SoapVar ($body_xml, XSD_ANYXML);
    return $result;
}

This is what I get in response:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <GetDetailsResponse>
            <Name>My name</Name>
        </GetDetailsResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is what I want to get in response:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <GetDetailsResponse>
            <Name>My name</Name>
        </GetDetailsResponse>
    </s:Body>
</s:Envelope>
0
source share

All Articles