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 6201895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:38:12+00:00 2026-05-24T04:38:12+00:00

I am using the SoapClient class in PHP to make a request. I am

  • 0

I am using the SoapClient class in PHP to make a request. I am trying to create a nested header variable to pass in my request.

Currently my request headers looks like this,

<SOAP-ENV:Header>
    <ns2:type>request</ns2:type>
    ...
</SOAP-ENV:Header>

I want it to look like this,

<SOAP-ENV:Header>
    <ns2:ei>
        <ns2:type>request</ns2:type>
        ...
    </ns2:ei>
</SOAP-ENV:Header>

I am currently creating the headers like this,

$headers[] = new SoapHeader(
        $nsp1,
        "type",
        "request"
    );
$headers[] = new SoapHeader(...)

I have tried various ways to nest the headers the including,

$headers[] = new SoapHeader(
   $nsp1,
   "ei",
   new SoapHeader(
        $nsp1,
        "type",
        "request"
    )
);

but this throws a fatal error.

  • 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-24T04:38:13+00:00Added an answer on May 24, 2026 at 4:38 am

    You can try using an object or an array as the $data parameter

    Object:

    <?php
    class MySoapHeader
    {
        public $type = 123;
        public $value = 'UNKNOWN';
    }
    
    $headers1[] = new SoapHeader(
            'n1',
            'ei',
            new MySoapHeader()
        );
    
    print_r ($headers1);
    ?>
    

    Gives

    Array ( [0] => SoapHeader Object ( [namespace] => n1 [name] => ei 
        [data] => MySoapHeader Object ( [type] => 123 [value] => UNKNOWN ) 
        [mustUnderstand] => ) ) 
    

    Array:

    <?php
        $headers2[] = new SoapHeader(
            'n1',
            'ei',
            array ('type'=>123,'value'=>'UNKNOWN')
        );
    
        print_r ($headers2);
    ?>
    

    Gives

    Array ( [0] => SoapHeader Object ( [namespace] => n1 [name] => ei
        [data] => Array ( [type] => 123 [value] => UNKNOWN ) [mustUnderstand]
        => ) )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, I am trying to consume a WebService using PHP SoapClient . Now,
Just to be clear before continuing: using PHP's built-in SOAP class is unfortunately not
I am struggling to get some SOAP request working using SOAP Ligth and PHP
I'm trying to consume a hello world AXIS2 SOAP web service using a PHP
Am trying to asynchronously send an email with an attachment using .net's SMPTClient class:
I'm trying to send an email message using the .NET MailMessage class which can
I make services folder in my Zend project and i create new php file
So I am trying to connect using SoapClient but am running into issues. $this->client
When sending email using the SMTPClient class in ASP.NET C#, how can I add
Duplicate of this question I'm trying to work with Zend_Soap using zend framework 1.9.6

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.