W jaki sposób dodać namespace w odpowiedzi na wywołanie metody? Muszę uzyskać efekt <XXX xmlns:"xxxx"> zamiast <XXX> Poniżej przedstawiam fragment kodu, obecną odpowiedź SOAP i odpowiedź, której potrzebuje. Niestety ogranicznikiem jest używanie SoapServera. Będę wdzięczny za każdą pomoc!
Pozdrawiam,
Sławek
function Register($TimeStamp) { $output = '<ns1:RegisterResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:RegistrationResponse"><ns1:TimeStamp>'.$nTimeStamp."</ns1:TimeStamp</ns1:RegisterResult>"; $response = '<ns1:RegisterResponse xmlns="http://tempuri.org">'.$output.' </ns1:RegisterResponse>'; $response = new SoapVar($output,XSD_ANYXML); return $response; } $server = new SoapServer(null, array('uri'=>'http://tempuri.org', 'soap_version' => SOAP_1_1, "style" => SOAP_DOCUMENT,"use" => SOAP_LITERAL)); $server->addFunction("Register"); $server->handle(); ?>
Odpowiedź obecna:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:RegisterResponse> <ns1:RegisterResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:RegistrationResponse"> <ns1:TimeStamp>2013303T142249</ns1:TimeStamp> </ns1:RegisterResult></ns1:RegisterResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Odpowiedź oczekiwana:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:RegisterResponse xmlns:="http://tempuri.org"> <ns1:RegisterResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:RegistrationResponse"> <ns1:TimeStamp>2013303T142249</ns1:TimeStamp> </ns1:RegisterResult></ns1:RegisterResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>