没有的.asmx分机呼叫的IIS Web服务有的、分机、Web、asmx

2023-09-02 02:01:06 作者:牵猫散步的鱼

我已经写了.NET Web服务要由我控制之外的客户端使用(我的服务器是一个模拟器为用PHP编写的一个活的服务器)。 Web服务作为工作所需,但客户端没有添加的.asmx扩展名,或者任何扩展为此事,在他们的呼叫。他们基本上使用的http://本地主机/ SOAP /为MyWebService 而IIS预计的 HTTP://localhost/soap/MyWebService.asmx 。有没有什么办法能让请求IIS响应无的.asmx扩展?

I have written a .NET web Service that is to be consumed by a client outside of my control (my server is a simulator for a live server written in PHP). The web service works as desired but the client does not have the ability to add the .asmx extension, or any extension for that matter, in their calls. They basically use http://localhost/soap/MyWebService while IIS expects http://localhost/soap/MyWebService.asmx. Is there any way to make IIS respond to requests without the .asmx extension?

推荐答案

添加一个通配符映射,这将借道ASP.NET的所有请求:

Add a wildcard mapping, which will route all requests through ASP.NET:

http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx

你也需要做一些URL重写,以允许传入的请求的http://本地主机/ SOAP /为MyWebService 映射到 HTTP://localhost/soap/MyWebService.asmx

You'll also need to do some URL rewriting, to allow the incoming request http://localhost/soap/MyWebService to map to http://localhost/soap/MyWebService.asmx.

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

基本上,你可以添加类似下面的内容到你的的Application_BeginRequest 方法:

Basically, you could add something like the following to your Application_BeginRequest method:

string path = Request.Path;
if (path.Contains("/soap/") && !path.EndsWith(".asmx"))
    Context.RewritePath(path + ".asmx");

我没有测试它(和它的一个黑客),但它应该让你开始。

I haven't tested it (and it's a HACK) but it should get you started.

 
精彩推荐