Witam serdecznie,

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

  1. function Register($TimeStamp)
  2. {
  3. $output = '<ns1:RegisterResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:RegistrationResponse"><ns1:TimeStamp>'.$nTimeStamp."</ns1:TimeStamp</ns1:RegisterResult>";
  4.  
  5. $response = '<ns1:RegisterResponse xmlns="http://tempuri.org">'.$output.' </ns1:RegisterResponse>';
  6. $response = new SoapVar($output,XSD_ANYXML);
  7.  
  8. return $response;
  9. }
  10.  
  11. $server = new SoapServer(null, array('uri'=>'http://tempuri.org', 'soap_version' => SOAP_1_1, "style" => SOAP_DOCUMENT,"use" => SOAP_LITERAL));
  12. $server->addFunction("Register");
  13. $server->handle();
  14. ?>


Odpowiedź obecna:
  1. <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/">
  2. <SOAP-ENV:Body>
  3. <ns1:RegisterResponse>
  4. <ns1:RegisterResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:RegistrationResponse">
  5.  
  6. <ns1:TimeStamp>2013303T142249</ns1:TimeStamp>
  7.  
  8.  
  9. </ns1:RegisterResult></ns1:RegisterResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>


Odpowiedź oczekiwana:
  1. <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/">
  2. <SOAP-ENV:Body>
  3. <ns1:RegisterResponse xmlns:="http://tempuri.org">
  4. <ns1:RegisterResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:RegistrationResponse">
  5.  
  6. <ns1:TimeStamp>2013303T142249</ns1:TimeStamp>
  7.  
  8.  
  9. </ns1:RegisterResult></ns1:RegisterResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>