Reputation: 11
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>
Upvotes: 1
Views: 2351
Reputation: 93
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);
?>
Upvotes: 1
Reputation: 70577
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
Upvotes: 1