【发布时间】:2011-01-07 16:55:18
【问题描述】:
我有办法知道请求是否是 HttpApplication 的 AuthenticateRequest 事件上的肥皂请求?检查 ServerVariables["HTTP_SOAPACTION"] 似乎并非一直有效。
public void Init(HttpApplication context) {
context.AuthenticateRequest += new EventHandler(AuthenticateRequest);
}
protected void AuthenticateRequest(object sender, EventArgs e) {
app = sender as HttpApplication;
if (app.Request.ServerVariables["HTTP_SOAPACTION"] != null) {
// a few requests do not enter here, but my webservice class still executing
// ...
}
}
我在我的 web.config 文件中禁用了 Web 服务的 HTTP POST 和 HTTP GET。
<webServices>
<protocols>
<remove name="HttpGet" />
<remove name="HttpPost" />
<add name="AnyHttpSoap" />
</protocols>
</webServices>
查看soap+xml 的ContentType 只能部分解决我的问题。例如,
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 1131
Content-Type: text/xml
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: ro
Host: localhost
mymethod: urn:http://www.wsnamespace.com/myservice
有些客户端没有标准头 SOAPAction:“http://www.wsnamespace.com/myservice/mymethod”,而是有一些类似于上面示例的内容。 “mymethod”表示我的 Web 服务类中带有 [WebMethod] 属性的方法,“http://www.wsnamespace.com/myservice”是 Web 服务的命名空间。服务仍然完全正常。 消费者使用不同的框架(来自 PHP、.NET、Java 等的 NuSOAP)。
【问题讨论】:
标签: asp.net web-services asmx