NuSOAP - 创建具有身份验证的服务器
我已经使用 NuSoap 库创建了 WebService,但我找不到如何实现身份验证的任何地方。 基本上我想要的是从 C# 连接到此服务并使用用户名和密码添加 NetworkCredential。
userdatawsdl d = new userdatawsdl();
d.Credentials = new NetworkCredential("test", "test");
val = d.GetUserData("x");
所以基本上我需要在 php 脚本中执行以下操作才能接受此数据并自动验证客户端请求。
这就是我的 php 脚本现在的样子,我已经排除了已注册的方法
require_once('lib/nusoap.php');
// create the server object
$server = new soap_server;
// Initialize WSDL support
$server->configureWSDL('userdatawsdl', 'urn:userdatawsdl');
// register soap functions
$server->register('GetUserData', array('memberNumber' => 'xsd:string'), array('result' => 'xsd:string'));
$server->register('GetUserStatus', array('memberNumber' => 'xsd:string'), array('result' => 'xsd:string'));
if (isset($error))
{
$fault =
$server->fault('soap:Server','',$error);
}
// send the result as a SOAP response over HTTP
$server->service($HTTP_RAW_POST_DATA);
I've created WebService using NuSoap library, but I can't find anywhere how to implement authentication.
Basically what I want is to connect to this service from C# and add NetworkCredential with the username and password.
userdatawsdl d = new userdatawsdl();
d.Credentials = new NetworkCredential("test", "test");
val = d.GetUserData("x");
So basically what I need to do in php script in order to accept this data and automatically authenticate client request.
This is how my php script looks like now, I have excluded methods which are registered
require_once('lib/nusoap.php');
// create the server object
$server = new soap_server;
// Initialize WSDL support
$server->configureWSDL('userdatawsdl', 'urn:userdatawsdl');
// register soap functions
$server->register('GetUserData', array('memberNumber' => 'xsd:string'), array('result' => 'xsd:string'));
$server->register('GetUserStatus', array('memberNumber' => 'xsd:string'), array('result' => 'xsd:string'));
if (isset($error))
{
$fault =
$server->fault('soap:Server','',$error);
}
// send the result as a SOAP response over HTTP
$server->service($HTTP_RAW_POST_DATA);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个:它涵盖了使用 NuSOAP 在 SOAP 服务器中实现身份验证,听起来像你想要什么。
Take a look at this: it covers implementing authentication in a SOAP server with NuSOAP, which sounds like what you want.