Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 524831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:36:32+00:00 2026-05-13T08:36:32+00:00

I am building (in PHP) a SOAP server that is configured by its WSDL

  • 0

I am building (in PHP) a SOAP server that is configured by its WSDL to accept messages that look like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://my.awesome.namespace/">
    <SOAP-ENV:Header>
        <ns1:Header>
            <ns1:APIKey>E4C5BDE0-48DC-543C-1CA3-8E55C63F8E60</ns1:APIKey>
            <ns1:SiteID>111</ns1:SiteID>
        </ns1:Header>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:Heartbeat>
            <ns1:Message>Hello world.</ns1:Message>
        </ns1:Heartbeat>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I had no problem getting my SOAPServer to process Heartbeat messages – $server->addFunction("Heartbeat"); works fine. I want, however, to be able to process the contents of the <ns1:Header> enclosure – so I can validate the API key and Site ID to make sure they are what they should be.

I looked here, (and of course elsewhere) but the responder seems to have missed the point of the question. Does anyone know how I can access the header element to validate? Do I add a function for Header the way I would a method in the body? ($server->addFunction("Header");?)

Thanks very much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:36:32+00:00Added an answer on May 13, 2026 at 8:36 am

    Found it! Here’s what you do.

    Create your SOAP server:

    $server = new SoapServer($your_wsdl,$any_options);
    $server->setClass($name_of_your_class);
    $server->handle($location_of_request_data);
    

    The class named in $name_of_your_class, in addition to containing functions for each service defined in $your_wsdl, should also contain a function named for whatever you have in your <SOAP-ENV:Header> tag enclosure. I have <ns1:Header>, so my function is named Header. Put whatever logic you need in there. For me, I wanted to validate the API key and site ID, so I created a private variable, and if the API key and site ID are correct, the variable is set to true. All of the other functions in the class check to see if that variable is true before proceeding, and if not, a SOAPFault is thrown.

    Hope this helps anyone who comes across this question on Google.

    P.S.: For the functions in the class defined in $server->setClass(), don’t forget that they must accept arguments in the order defined in the WSDL. That tripped me up.

    Good luck to all other PHP/SOAP developers – seems like we all need it.

    Edit/P.P.S.: For whatever reason, simply calling $server->addFunction("Header") did not work for me – I tried that first before I tried the setClass approach above. Just a heads-up to folks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 303k
  • Answers 303k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Hmm, perhaps the tables aren't really tables. They could be… May 13, 2026 at 8:38 pm
  • Editorial Team
    Editorial Team added an answer EDIT As described by your later comment, you only want… May 13, 2026 at 8:38 pm
  • Editorial Team
    Editorial Team added an answer Try ime-mode: active in css style, basically you could set… May 13, 2026 at 8:38 pm

Related Questions

I am building a website in CakePHP that processes files uploaded though an XML-RPC
I am building a PHP application in CodeIgniter. CodeIgniter sends all requests to the
What are some strategies to achieve code separation in AJAX applications? I am building
Greetings all! Looking for some help with MVC in a PHP context. Currently I
I am building a web site in PHP that integrates with Youtube. I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.