在 PHP Soap Server 中收集/处理标头 [英] Collecting/Processing headers in PHP Soap Server

查看:29
本文介绍了在 PHP Soap Server 中收集/处理标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PHP5 的本机 SOAP 方法创建 Web 服务.一切都很顺利,直到我尝试使用 SOAP 标头处理身份验证.

I'm creating a web service using PHP5's native SOAP Methods. Everything went fine until I tried to handle authentication using SOAP Headers.

我可以轻松找到如何将用户名/密码添加到 SOAP 标头中,客户端:

I could easily find how to add the username/password to the SOAP headers, client-side:

$myclient = new SoapClient($wsdl, $options);

$login = new SOAPHeader($wsdl, 'email', 'mylogin');
$password = new SOAPHeader($wsdl, 'password', 'mypassword');
$headers = array($login, $password);

$myclient->__setSOAPHeaders($headers);

但是我在任何地方都找不到服务器端收集和处理这些标头的方法.我猜必须有一种简单的方法来在我的 SoapServer 中定义一个处理标题的方法......

But I can't find anywhere the methods for collecting and processing these headers server-side. I'm guessing there has to be an easy way to define a method in my SoapServer that handles the headers...

推荐答案

SoapClient 使用用户名和密码来实现 HTTP 身份验证.支持基本和摘要认证(见源)

SoapClient uses the username and password to implement HTTP authentication. Basic and Digest authentication are support (see source)

关于在服务器端在 PHP 中实现 HTTP 身份验证的信息,请参阅本手册页.

For information on implementing HTTP authentication in PHP on the server side, see this manual page.

如果您不想使用 HTTP 身份验证,请参阅此用户-SoapServer 手册页上的贡献示例,展示了如何在 UsernameToken 标头中传递一些凭据.

If you don't want to use HTTP authentication, see this user-contributed sample on the SoapServer manual page which shows how you could pass some credentials in a UsernameToken header.

这篇关于在 PHP Soap Server 中收集/处理标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆