WCF:需要使用HTTP标头或查询的Apikey保护WSDL和SOAP调用
我有一个普通的WCF服务,该服务被暴露为肥皂服务,我需要用Apikey保护它,该apikey将在HTTP标头或HTTP查询参数中提供。 WSDL的检索和Web服务的消费均必须受到保护,但此速度都必须进行。最后,如果验证失败,则必须返回带有HTTP状态代码的空文档。
我尝试了使用行为的各种事情,但是最好的努力只能确保消耗部分,而我无法返回一个空文档(始终返回soap FARD XML XML文档,并带有我的例外详细信息)。我无法拦截WSDL生成并返回401/403 HTTP状态代码。
我意识到这是非标准的,但这就是向我提出要求的方式。
我认为这是可能的,但我不知所措。
该项目基本上只有1个.CS文件,其中包含所需的接口及其实现:
[ServiceContract]
public interface IFooService
{
[OperationContract]
barOut Lookup(string baz);
}
如果有人这样做,我想获得一些指示。
I have a normal WCF service that is exposed as a SOAP service and I need to secure it with an ApiKey that will be provided in either the HTTP header or as a HTTP query parameter. Both the retrieval of the WSDL and the consuming of the web service must be protected but this ApiKey. Finally, if validation fails, an empty document with an HTTP status code must be returned.
I have tried various stuff using behaviors but the best effort only secured the consuming part and I was unable to return an empty document (always returned a SOAP fault XML document with my exception details). I have not been able to intercept the WSDL generation and return 401/403 HTTP status code.
I realize this is non-standard, but this is how the requirements are presented to me.
I assume this is possible, but I am at a loss.
The project basically only has 1 .cs file containing the required interface and the implementation thereof:
[ServiceContract]
public interface IFooService
{
[OperationContract]
barOut Lookup(string baz);
}
If anyone has done this, I'd like to get some pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案很简单。我可以使用
application_beginrequest
在global.asax.cs
中覆盖,该在每个请求中都调用,它是WSDL检索或消耗SOAP服务:The solution turned out to be quite simple. I could use the
Application_BeginRequest
override inGlobal.asax.cs
that is being called on each request, it being WSDL retrieval or consuming the SOAP service: