Jump to content

Recommended Posts

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>

 

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?

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?

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 by immortallch
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.