如何创建像这样的soap标头:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<requestHeader>
<user>
<userId>ID</userId>
<password>Password</password>
</user>
<service>service</service>
</requestHeader>
答案 0 :(得分:1)
您需要创建的内容并不是很明显,但通常是PHP DOM系列函数:
http://php.net/manual/en/book.dom.php
允许生成XML,将结果保存为字符串以供进一步使用。如果您正在通过SOAP进行通信,或者想要创建SOAP服务器,那么PHP SOAP函数是一个很好的资源:
答案 1 :(得分:1)
我认为你在谈论一个客户端头,这是“登录”到SOAP服务器所必需的,因此基于这个假设,这看起来就像你要做的事情:
<?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);
?>