SOAP request with header data

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:

  <OutgoingHeaders attr0="MsgHeaderArray" isNull="false">

Open in new window

The code I'm using to connect to the api and call the method is:

$params = array(
  'colour' => 'Red', 
  'size' => 'Large'
$service = new SoapClient('');
$header = new SoapHeader('', 'ApiKey', 'ABC123', FALSE);

Open in new window

However I'm getting an access denied error, I'm guessing because SoapHeader isn't corrently formatted?

SoapFault: Access is denied. in SoapClient->__call()

Open in new window

Thank you for any help you can provide.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amar BardoliwalaCommented:
Hello Mr_Splash,

Looking at your code, it seems fine.

Seems that Direction is missing in your request header.

Otherwise, it seems fine.

Might be problem with wrong api key.

Have you checked it?

Look at following pages for more help on php soap

Hope this will help you.

Thank You.


Mr_SplashAuthor Commented:
Thanks amar but I can confirm the api is correct as I can connect through a WCF client. The issue is passing the equivalent as SOAP.
Amar BardoliwalaCommented:
Hello Mr_Splash,

Did you try to look at links above?

There are some examples given on that about how to use SOAP with PHP

Thank You.

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Mr_SplashAuthor Commented:
Thanks amar, I'm familiar with using SOAP with PHP and my code looks very similar to the examples. Which is why I'm looking for help specifically with creating the header to match the WCF example..
Mr_SplashAuthor Commented:
Had to post raw SOAP through cURL in the end.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mr_SplashAuthor Commented:
No workable solution put forward
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.