设置自定义SoapServer响应的命名空间

时间:2014-08-15 14:43:07

标签: php xml soap

我正在创建Soap服务器端。

有没有办法更改soap envelope,body和header标签的默认命名空间?

要处理请求,请使用以下代码:

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;
}

这是我的回应:

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

这是我想要回应的内容:

<?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 个答案:

没有答案