在 C# Web 服务中隐藏函数输入参数?
我有一个关于是否可以隐藏 Web 服务方法的输入的问题。
假设第四个参数采用密码作为输入,并且我们希望该输入仅在客户端使用。
该函数有 4 个输入参数,有什么方法可以保留该函数的所有输入参数,但在通过网络浏览器访问 .asmx 文件时使第四个参数不可见?这是为了消除用户尝试访问服务并尝试输入随机数据。
编辑: 将其放在示例中。
我们有一个 iPhone 应用程序,当用户使用某个功能时,一些参数会与第四个参数一起发送到 Web 服务,该参数应包含某种密钥以验证用户是否在实际的 iPhone 上使用该应用程序而不是访问网络服务的人试图访问数据。
public someVariable someFunction(someVar parameter1,someVar parameter2,someVar parameter3,someVar parameter4)
{
if (key.isMatch(parameter4))
{
The user is on an iPhone using the app : Proceeding.
}
else
The user is not on an iPhone, cancelling function.
}
I have a question regarding if it is possible to hide inputs to a web-service method.
Lets say that the fourth parameter takes a password as input, and we want this input only to be used on the client side.
The function has 4 input parameters, and is there any way possible to still have all the input parameters to the function but make the fourth parameter invisible when accessing the .asmx file through the web-browser? This is to eliminate users trying to access the service and trying to input random data.
EDIT: To place this in an example.
We have an iPhone application, when a user makes use of a function, some parameters are sent to the web-service along with the fourth parameter that should contain a key of some sort to validate that the user is on an actual iPhone using the application and not someone accessing the web-service trying to access data.
public someVariable someFunction(someVar parameter1,someVar parameter2,someVar parameter3,someVar parameter4)
{
if (key.isMatch(parameter4))
{
The user is on an iPhone using the app : Proceeding.
}
else
The user is not on an iPhone, cancelling function.
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过扩展 SoapExtension 并获取肥皂头形式的额外信息来防止从网络浏览器调用您的方法,这些信息只能由最终用户应用程序发送,
请查看此 在 Web 服务中使用 SOAP 标头和 SOAP 扩展
you can prevent calling your method from webbrowser,by extending SoapExtension and getting extra information as soapheader ,that just can be send by enduser app
have a look to this Using SOAP Header and SOAP Extensions in a Web Service
您正在使用的界面不应该用于测试以外的任何用途。
如果您需要在生产中使用它,您应该实现自己的页面,因此参数 4 的文本框将被屏蔽。
The interface that you are using was not supposed to be used for anything but testing.
If you need to use it on production you should rather implement your own page, so the TextBox for parameter 4 would be masked.