1

How can I create a soap header like that:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<requestHeader>
<user>
<userId>ID</userId>
<password>Password</password>
</user>
<service>service</service>
</requestHeader>
onteria_
  • 68,181
  • 7
  • 71
  • 64
user748536
  • 11
  • 3

2 Answers2

1

It's not too apparent what you need the creation for, but in general the PHP DOM series of functions:

http://php.net/manual/en/book.dom.php

Allows for generation of XML, saving the result to a string for further use. If you're communicating through SOAP, or wanting to make a SOAP server, the PHP SOAP functions are a good resource:

http://www.php.net/manual/en/book.soap.php

onteria_
  • 68,181
  • 7
  • 71
  • 64
1

I think you're talking about a client header that's mandatory for "logging in" to a SOAP server, so based on that assumption, this looks like the thing you want to do:

<?php 
$ns = 'urn:namespace'; // the namespace for the request, you don't appear to have any

// actual header construction, based on your structure
$soapHeader = array('user' => array( 
                      'userId' => $__yourUserID, 
                      'password' => $__yourUserPassword,
                    ),
                    'service' => $__yourService,
);

// Soap Header initialization
$header = new SOAPHeader($ns, 'requestHeader', $soapHeader);        

// add the Header to the Soap Client before request
$soap_client->__setSoapHeaders($header); 

?>
Elis
  • 93
  • 6