I'm trying to connect to a WCF service from PHP using the SoapClient class. I can successfully connect and traverse the API using WCFStorm however cannot seem to construct the header data correctly in order to authenticate from SoapClient. A working WCF request would be as follows:
<MyMethod>
<OutgoingHeaders attr0="MsgHeaderArray" isNull="false">
<MsgHeaderArray0>
<Name>ApiKey</Name>
<Namespace>http://www.service.com/namespace</Namespace>
<ItemType>System.String</ItemType>
<Value>ABC123</Value>
<Direction>Outgoing</Direction>
</MsgHeaderArray0>
</OutgoingHeaders>
<MethodParameters>
<colour>Red</colour>
<size>Large</size>
</MethodParameters>
</MyMethod>
The code I'm using to connect to the api and call the method is:
$params = array(
'colour' => 'Red',
'size' => 'Large'
);
$service = new SoapClient('http://www.service.com/service.svc?wsdl');
$header = new SoapHeader('http://www.service.com/namespace', 'ApiKey', 'ABC123', FALSE);
$service->__setSoapHeaders(array($header));
$service->MyMethod($params);
However I'm getting an access denied error, I'm guessing because SoapHeader isn't corrently formatted?
SoapFault: Access is denied. in SoapClient->__call()
Thank you for any help you can provide.