如何在 PHP 中创建肥皂头?

发布于 2024-11-06 10:06:23 字数 294 浏览 4 评论 0原文

我怎样才能创建这样的肥皂头:

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽袖吟 2024-11-13 10:06:23

你需要创建什么并不是太明显,但总的来说 PHP DOM 系列函数:

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

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

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

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

枯寂 2024-11-13 10:06:23

我认为您正在谈论“登录”到 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); 

?>

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

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文