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

  • SEARCH
  • Home
  • 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 178433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:13:49+00:00 2026-05-11T14:13:49+00:00

Doing some SOAP calls to a 3rd party application. They provide this soap header

  • 0

Doing some SOAP calls to a 3rd party application. They provide this soap header as an example of what the application expects. How can I create a SOAP header like this in PHP?

<SOAP-ENV:Header>     <NS1:Security xsi:type='NS2:Security' xmlns:NS1='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:NS2='urn:dkWSValueObjects'>         <NS2:UsernameToken xsi:type='NS2:TUsernameToken'>             <Username xsi:type='xsd:string'>XXXX</Username>              <Password xsi:type='xsd:string'>XXX</Password>          </NS2:UsernameToken>     </NS1:Security> </SOAP-ENV:Header> 

I do what i think is a correct call and keep getting in return that no headers were sent.

Here is a sample from my code.

class SOAPStruct  {     function __construct($user, $pass)      {         $this->Username = $user;         $this->Password = $pass;     } }  $client = new SoapClient('http://www.example.com/service');  $auth = new SOAPStruct('username', 'password'); $header = new SoapHeader('http://example.com/service', 'TUsernameToken', $auth);  $client->__setSoapHeaders(array($header)); $client->__soapCall('GetSubscriptionGroupTypes', array(), NULL, $header) 

And this is the SOAP header i get back. (its more but i stripped info away that might be sensitive)

<SOAP-ENV:Header>     <ns2:TUsernameToken>         <Username>username</Username>          <Password>password</Password>      </ns2:TUsernameToken> </SOAP-ENV:Header> 
  • 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. 2026-05-11T14:13:50+00:00Added an answer on May 11, 2026 at 2:13 pm

    SOAP header handling in PHP is actually not very flexible and I’d go as far as saying that especially the use two namespaces within the header will make it impossible to inject the header simply by using a SoapHeader-construct of some type.

    I think the best way to handle this one is to shape the XML request yourself by overriding SoapClient::__doRequest() in a custom class that extends SoapClient.

    class My_SoapClient extends SoapClient {     public function __doRequest($request, $location, $action, $version, $one_way = 0)     {         $xmlRequest = new DOMDocument('1.0');         $xmlRequest->loadXML($request);          /*          * Do your processing using DOM           * e.g. insert security header and so on          */          $request = $xmlRequest->saveXML();         return parent::__doRequest($request, $location, $action, $version, $one_way);     } } 

    Please see SoapClient::__doRequest for further information and some examples.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Something has gotten out of sync or has become corrupt,… May 12, 2026 at 1:13 am
  • Editorial Team
    Editorial Team added an answer There is no direct way to do this that I'm… May 12, 2026 at 1:13 am
  • Editorial Team
    Editorial Team added an answer The non persistent cookie will automatically delete when the browser… May 12, 2026 at 1:13 am

Related Questions

I've been working with JAX-WS with Weblogic Server, using their Ant tasks to build
I have a web application deployed in an internet hosting provider. This web application
We are trying to copy a BO Query Service from one Universe to another.
I am maintaining a SOAP web service (ASP.NET version 2.0) and I have to

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.