T
T
Twist2015-01-08 20:48:01
PHP
Twist, 2015-01-08 20:48:01

How to correctly set the authentication token for a SOAP request?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
   <soapenv:Header>
      <urn:OTAuthentication>
         <!--Optional:-->
         <urn:AuthenticationToken></urn:AuthenticationToken>
      </urn:OTAuthentication>
   </soapenv:Header>
   <soapenv:Body>
      <urn1:GetNodes>
         <!--Zero or more repetitions:-->
         <urn1:IDs>2005</urn1:IDs>
      </urn1:GetNodes>
   </soapenv:Body>
</soapenv:Envelope>

SOAP UI generates the following code, in php through SoapClient it is possible to set the variable IDs without problems, but I can not set the header for authentication.
How to set such a token correctly?
<soapenv:Header>
      <urn:OTAuthentication>
         <!--Optional:-->
         <urn:AuthenticationToken></urn:AuthenticationToken>
      </urn:OTAuthentication>
   </soapenv:Header>

I solved the problem, I will add the solution today

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danila, 2015-01-15
@Ke1eth

Class/stub for token

class Token {
    public $id;

    public function __construct($id) {
        $this->id = $id;
    }    
}

Create a title
You install it in the client:
That's it.

T
Twist, 2015-01-20
@bboytiwst

Here is how I managed to solve it

$strHeaderComponent_Session = "<ns2:PRostranstvo><ns2:AuthenticationToken>$token</ns2:AuthenticationToken></ns2:PRostranstvo>";
$objVar_Session_Inside = new SoapVar($strHeaderComponent_Session, XSD_ANYXML, null, null, null);
$objHeader_Session_Outside = new SoapHeader('urn:burum burum', 'PRostranstvo', $objVar_Session_Inside);
$this->client->__setSoapHeaders([$objHeader_Session_Outside]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question