1

如何创建这样的肥皂标题:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<requestHeader>
<user>
<userId>ID</userId>
<password>Password</password>
</user>
<service>service</service>
</requestHeader>
4

2 回答 2

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); 

?>
于 2011-05-11T12:30:33.613 回答
1

您需要创建什么并不是很明显,但通常是 PHP DOM 系列函数:

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

允许生成 XML,将结果保存为字符串以供进一步使用。如果您通过 SOAP 进行通信,或者想要创建一个 SOAP 服务器,那么 PHP SOAP 函数是一个很好的资源:

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

于 2011-05-11T11:44:24.690 回答