Roger Gajraj
Roger Gajraj

Reputation: 533

create SOAP header using PHP

I'm new to SOAP and I can't figure how to create a SOAP header using the following template:

I am programming in PHP using SoapClient.

 <SOAP-ENV:Header>
    <Username xmlns="http://something.com/WebServices/SMSPush">User</Username>
    <Password xmlns="http://something.com/WebServices/SMSPush">Pass</Password>
    <To SOAP-ENV:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://wsmcg002.something.sys:8004/SmsPushService.svc</To>
    <Action SOAP-ENV:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">SendMultipleTextMessage</Action>
</SOAP-ENV:Header>

Upvotes: 1

Views: 1262

Answers (1)

denisvm
denisvm

Reputation: 730

You set the SOAP header using SoapHeader class

<?php
$client = new SoapClient(...);

$headers = array();
$headers[] = new SoapHeader('http://something.com/WebServices/SMSPush', 'Username', 'Usser');
$headers[] = new SoapHeader('http://something.com/WebServices/SMSPush', 'Password', 'Pass');
$headers[] = new SoapHeader('http://schemas.microsoft.com/ws/2005/05/addressing/none', 'To', 'http://wsmcg002.something.sys:8004/SmsPushService.svc', true);
$headers[] = new SoapHeader('http://schemas.microsoft.com/ws/2005/05/addressing/none', 'Action', 'SendMultipleTextMessage', true);
$client->__setSoapHeaders($headers);

Upvotes: 2

Related Questions