immortallch Posted April 3, 2013 Share Posted April 3, 2013 Hey! How to add namespace on response? I need to get <RegisterResponse xmlns="http://tempuri.org"> but I only get <RegisterResponse> I would be greatful, If someone could help me (it's realy important to me) Here is PHP code, my SOAP response and proper response im looking into: 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(); ?> <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> <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> Quote Link to comment https://forums.phpfreaks.com/topic/276490-soapserver-how-to-add-namespace-to-response/ Share on other sites More sharing options...
requinix Posted April 3, 2013 Share Posted April 3, 2013 The only difference between the two is that the "proper response" includes an xmlns for a namespace that isn't used anywhere. It doesn't matter. So are you trying to do this for cosmetic purposes or is there a functional problem somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/276490-soapserver-how-to-add-namespace-to-response/#findComment-1422705 Share on other sites More sharing options...
salathe Posted April 3, 2013 Share Posted April 3, 2013 RegisterResponse is already in the http://tempuri.org namespace. You can see that in the document element's opening tag, a prefix is defined (xmlns:ns1="http://tempuri.org"), which is then used for RegisterResponse (ns1:RegisterResponse).I'm with requinix, do you have a functional problem or could you explain in more detail why you want the namespace declared in the RegisterResponse tag? Quote Link to comment https://forums.phpfreaks.com/topic/276490-soapserver-how-to-add-namespace-to-response/#findComment-1422716 Share on other sites More sharing options...
immortallch Posted April 3, 2013 Author Share Posted April 3, 2013 (edited) Well, I would say it is "cosmetic" problem. The response has to be parsable by external parser (I can't modify it) and without xmlns="http://tempuri.org" there are parse errors. Additionally I would also like to know how to change this: <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/"> to this: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org"> Edited April 3, 2013 by immortallch Quote Link to comment https://forums.phpfreaks.com/topic/276490-soapserver-how-to-add-namespace-to-response/#findComment-1422777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.