Need Assistance Producing Soap Header Using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MICAHGUARDIAN
Forum Newbie
Posts: 1
Joined: Thu Jun 26, 2014 1:44 pm

Need Assistance Producing Soap Header Using PHP

Post by MICAHGUARDIAN »

Can anyone show me how to produce and correctly format this soap/xml request using php?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="SPP.net/ContractData">
<soapenv:Header>
<con:AuthHeader>
<con:Username>SomeUserName</con:Username>
<con:Password>SomePassword</con:Password>
<con:contractID>123456</con:contractID>
<con:dealerCode>abcde</con:dealerCode>
</con:AuthHeader>
</soapenv:Header>
<soapenv:Body>
<con:Logon/>
</soapenv:Body>
</soapenv:Envelope>


The WSDL is: https://gmwstest.sppinc.net/VPP/Contrac ... .asmx?wsdl
User avatar
techkid
Forum Commoner
Posts: 54
Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives

Re: Need Assistance Producing Soap Header Using PHP

Post by techkid »

Try this:

Code: Select all

<?php

$wsdl = 'https://gmwstest.sppinc.net/VPP/ContractExchange.asmx?wsdl';
$name_space = 'SPP.net/ContractData';

$client = new SoapClient($wsdl);

$auth = array(
	'Username' => 'SomeUserName',
	'Password' => 'SomePassword',
	'contractID' => '123456',
	'dealerCode' => 'abcde'
);

$header = new SoapHeader($name_space, 'AuthHeader', $auth, false);
$client->__setSoapHeaders($header);
Post Reply