Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set this php soap header?

Tags:

php

soap

header

How do i set this php Soap Header ?? For the life of me I can't figure it out.

   <soapenv:Header>
    <wsse:HeaderOne soapenv:mustUnderstand="1">
        <wsse:UsernameKey wsu:Id="tun-12345">
            <wsse:Username>myusername</wsse:Username>
            <wsse:Password>mypassword</wsse:Password>
        </wsse:UsernameKey>
    </wsse:HeaderOne>
   </soapenv:Header>

Thanks guys !

like image 819
koos Avatar asked Aug 22 '11 08:08

koos


People also ask

How do you set headers in SOAP request?

Select the service task or web service integration component and click the Variables tab above the diagram area. Create the private variable that you will later map to the SOAP header of the request message. To add a single header entry to the request message, use the variable type SOAPHeader.

How can make SOAP call in PHP?

To make SOAP requests to the SOAP API endpoint, use the "Content-Type: application/soap+xml" request header, which tells the server that the request body contains a SOAP envelope. The server informs the client that it has returned a SOAP envelope with a "Content-Type: application/soap+xml" response header.

What is PHP SOAP Extension?

A PHP SOAP Extension can be used to provide and consume Web services. In other words, this PHP extension can be used by PHP developers to write their own Web Services, as well as to write clients to make use of the existing Web services.

What is SOAP header?

The SOAP <Header> is an optional element in a SOAP message. It is used to pass application-related information that is to be processed by SOAP nodes along the message path. The immediate child elements of the <Header> element are called header blocks.


1 Answers

See this comment:

http://www.php.net/manual/en/soapclient.setsoapheaders.php#93460

So it would be like:

$headerbody = array('UsernameKey'=>array('Username'=>$UserID,
                                         'Password'=>$Pwd)); 
$header = new SoapHeader($ns, 'RequestorCredentials', $headerbody);       

//set the Headers of Soap Client.
$soap_client->__setSoapHeaders($header); 
like image 98
rickyduck Avatar answered Nov 10 '22 02:11

rickyduck